Polishing contribution

See gh-25856
This commit is contained in:
Rossen Stoyanchev 2020-10-15 10:14:01 +01:00
parent babcbd0d2b
commit 4952336419
1 changed files with 7 additions and 6 deletions

View File

@ -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);
}