Made sure the connection is disconnected
This commit is contained in:
parent
137201c3e7
commit
76f78a8688
1 changed files with 18 additions and 14 deletions
|
@ -51,6 +51,7 @@ internal fun fetchUrl(url: String, auth: String = ""): String {
|
|||
}
|
||||
|
||||
val connection = URL(url).openConnection() as HttpURLConnection
|
||||
try {
|
||||
connection.setRequestProperty(
|
||||
"User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0"
|
||||
)
|
||||
|
@ -67,6 +68,9 @@ internal fun fetchUrl(url: String, auth: String = ""): String {
|
|||
} else {
|
||||
throw httpError(connection.responseCode)
|
||||
}
|
||||
} finally {
|
||||
connection.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
private fun httpError(responseCode: Int): HttpErrorException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue