Skip to content

Commit

Permalink
Merge pull request #227 from viguice/viguice
Browse files Browse the repository at this point in the history
Workaround when proxy returns HTTP_PROXY_AUTH code
  • Loading branch information
amattioc committed Jul 21, 2023
2 parents 1c77445 + 896f14d commit 5475b3e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,19 @@ protected final <T> T runQuery(Parser<T> parser, URL query, String acceptHeader,
}

code = conn instanceof HttpURLConnection ? ((HttpURLConnection) conn).getResponseCode() : HttpURLConnection.HTTP_OK;
if (code == HttpURLConnection.HTTP_PROXY_AUTH)
{
LOGGER.fine("Error with proxy. Second attempt after forcing acces to http website in first place.");
URI uritest= new URI("http://google.com");
URL urltest = uritest.toURL();
conn = urltest.openConnection(proxy);
((HttpURLConnection) conn).setRequestMethod("GET");
code = conn instanceof HttpURLConnection ? ((HttpURLConnection) conn).getResponseCode() : HttpURLConnection.HTTP_OK;
conn = url.openConnection(proxy);
((HttpURLConnection) conn).setRequestMethod("GET");
code = conn instanceof HttpURLConnection ? ((HttpURLConnection) conn).getResponseCode() : HttpURLConnection.HTTP_OK;

}
if (isRedirection(code))
{
URL redirection = getRedirectionURL(conn, code);
Expand Down

0 comments on commit 5475b3e

Please sign in to comment.