Java HttpsURLConnection的默认请求方法

Java HttpsURLConnection的默认请求方法,java,http,https,Java,Http,Https,javax.net.ssl.HttpsURLConnection的默认请求方法是什么? 这就是如果我没有明确指定任何方法类型,那么是默认的GET还是POST 以下代码中使用了什么方法类型—GET?或POST? protected URLConnection createUrlConnection(URL url) throws IOException, GeneralSecurityException, LinkKeyStoreException {

javax.net.ssl.HttpsURLConnection
的默认请求方法是什么? 这就是如果我没有明确指定任何方法类型,那么是默认的
GET
还是
POST

以下代码中使用了什么方法类型—
GET?
POST?

protected URLConnection createUrlConnection(URL url) throws IOException,
            GeneralSecurityException, LinkKeyStoreException
    {
        URLConnection urlConnection = url.openConnection();
        if (urlConnection instanceof HttpsURLConnection)
        {
            ((HttpsURLConnection) urlConnection).setHostnameVerifier(Constants.ACCEPT_ALL_HOSTS);
            ((HttpsURLConnection) urlConnection).setSSLSocketFactory(createSSLSocketFactory());
        }
        urlConnection.setConnectTimeout(Constants.URL_CONNECT_TIMEOUT);
        urlConnection.setReadTimeout(Constants.URL_READ_TIMEOUT);
        urlConnection.setRequestProperty("Range", "bytes=" + totalBytesDownloaded + "-");
        urlConnection.connect();
        return urlConnection;
    }

HttpURLConnection默认使用GET方法。

默认方法是
GET
,for
HttpURLConnection#setRequestMethod
提示:

设置URL请求的方法,方法之一: 得到 邮递 头 选择权 放 删除 痕迹 是合法的,受协议限制默认方法是GET。


不适用于这个Q,javadoc没有说明,但是如果您为请求体提供
.setDoOutput(true)
.getOutputStream()
,而不显式更改它使用POST的方法,因为HTTP禁止GET上的体。@dave\u thompson\u 085是的……我在源代码中也看到了
if
语句。