HTTPURLConnection Doesn't Follow Redirect from HTTP to HTTPS

后端 未结 6 523
时光取名叫无心
时光取名叫无心 2020-11-22 10:39

I can\'t understand why Java\'s HttpURLConnection does not follow an HTTP redirect from an HTTP to an HTTPS URL. I use the following code to get the page at htt

6条回答
  •  执笔经年
    2020-11-22 11:05

    Has something called HttpURLConnection.setFollowRedirects(false) by any chance?

    You could always call

    conn.setInstanceFollowRedirects(true);
    

    if you want to make sure you don't affect the rest of the behaviour of the app.

提交回复
热议问题