Getting http 407 error as an IOException

I'm using in my android application the HttpURLConnection through a proxy where an authentication is needed. Here is my code and I will explain you after my problem. HttpURLConnection connection = null; int responseCode = -1; try { connection = (HttpURLConnection) myUrl.openConnection(); connection.setInstanceFollowRedirects(false); connection.setConnectTimeout(DEFAULT_TIMEOUT); connection.setReadTimeout(DEFAULT_TIMEOUT); responseCode = connection.getResponseCode(); System.out.println("ResponseCode = " + responseCode); } catch (IOException e) { System.out.println("Exception : " + e.getMessage()); } My problem is that I get an exception on the getResponseCode() method which has the following message : Failed to authenticate with proxy. Usually, this specific error has an http error code : 407. But here I just got an exception but not a response code with the 407 value. I have the solution to apply the login and password to connect to the proxy, but I want to apply this solution only in the case there is a 407 error (and not each time I catch an exception). Any idea will be appreciated. Thanks.
did you find solution for this one? Answer from Tonio doesn't help.

以上就是Getting http 407 error as an IOException的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏