Polishing contribution
See gh-25856
This commit is contained in:
@@ -186,7 +186,8 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
|
||||
protected HttpURLConnection openConnection(URL url, @Nullable Proxy proxy) throws IOException {
|
||||
URLConnection urlConnection = (proxy != null ? url.openConnection(proxy) : url.openConnection());
|
||||
if (!(urlConnection instanceof HttpURLConnection)) {
|
||||
throw new IllegalStateException("HttpURLConnection required for [" + url + "] but got: " + urlConnection);
|
||||
throw new IllegalStateException(
|
||||
"HttpURLConnection required for [" + url + "] but got: " + urlConnection);
|
||||
}
|
||||
return (HttpURLConnection) urlConnection;
|
||||
}
|
||||
@@ -206,13 +207,13 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
|
||||
connection.setReadTimeout(this.readTimeout);
|
||||
}
|
||||
|
||||
boolean mayWrite =
|
||||
("POST".equals(httpMethod) || "PUT".equals(httpMethod) ||
|
||||
"PATCH".equals(httpMethod) || "DELETE".equals(httpMethod));
|
||||
|
||||
connection.setDoInput(true);
|
||||
|
||||
connection.setInstanceFollowRedirects("GET".equals(httpMethod));
|
||||
|
||||
connection.setDoOutput("POST".equals(httpMethod) || "PUT".equals(httpMethod) ||
|
||||
"PATCH".equals(httpMethod) || "DELETE".equals(httpMethod));
|
||||
|
||||
connection.setDoOutput(mayWrite);
|
||||
connection.setRequestMethod(httpMethod);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user