httpurlconnectionhttpsurlconnection

Getting status 403 with HttpUrlConnection but 200 with HttpsUrlConnection


I am trying to get response code for site "https://www.applefcu.org/". When I run the code with "HttpUrlConnection", I am getting status code as 403, but when I run the code with "HttpsUrlConnection", it gives status 200.

What can be the reason for this? and how do I identify when to run this code with "HttpUrlConnection" and when with "HttpsUrlConnection"?


Solution

  • The info is right there in the address. If the URL says https:// use HttpsUrlConnection