Skip to content

Commit

Permalink
fix error when not using proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Apr 10, 2024
1 parent 3151696 commit c4250cc
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ class ImageDownloader {
try {
HttpURLConnection.setFollowRedirects(true)
var url = URL(imageUrl)
var huc = url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection
var huc =
if (HttpClientManager.getDefaultProxy() != null) {
url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection
} else {
url.openConnection() as HttpURLConnection
}
huc.instanceFollowRedirects = true
var responseCode = huc.responseCode

Expand All @@ -46,7 +51,12 @@ class ImageDownloader {

// open the new connnection again
url = URL(newUrl)
huc = url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection
huc =
if (HttpClientManager.getDefaultProxy() != null) {
url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection
} else {
url.openConnection() as HttpURLConnection
}
responseCode = huc.responseCode
}

Expand Down

0 comments on commit c4250cc

Please sign in to comment.