Difference between URLConnection, HttpURLConnection and HttpsURLConnection

后端 未结 2 548
囚心锁ツ
囚心锁ツ 2020-12-24 07:14

What is the difference between URLConnection, HttpURLConnection and HttpsURLConnection (with SSL). Under what conditions, which one sh

相关标签:
2条回答
  • 2020-12-24 07:22

    URLConnection is an abstract class so, you could never instantiate an object of that type.

    HttpURLConnection extends URLConnection and provides fields and methods specific to an HTTP URL, such as, HTTP_CLIENT_TIMEOUT or setRequestMethod.

    HttpsURLConnection extends HttpURLConnection and provides fields and methods specific to an HTTPS URL.

    0 讨论(0)
  • 2020-12-24 07:29

    URLConnection is the base class.

    HttpURLConnection is a derived class which you can use when you need the extra API and you are dealing with HTTP or HTTPS only.

    HttpsURLConnection is a 'more derived' class which you can use when you need the 'more extra' API and you are dealing with HTTPS only.

    All three of them are abstract, and implemented by specific classes you aren't privy to.

    0 讨论(0)
提交回复
热议问题