Skip to content

Commit

Permalink
8276798: HttpURLConnection sends invalid HTTP request
Browse files Browse the repository at this point in the history
Reviewed-by: dfuchs, michaelm
  • Loading branch information
jaikiran committed Jun 22, 2022
1 parent 270cf67 commit 50c37f5
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -626,10 +626,13 @@ private void writeRequests() throws IOException {
* to last and last, respectively, in the case of a POST
* request.
*/
if (!failedOnce) {
final String requestLine = method + " " + getRequestURI()+ " " + httpVersion;
final int requestLineIndex = requests.getKey(requestLine);
if (requestLineIndex != 0) {
// we expect the request line to be at index 0. we set it here
// if we don't find the request line at that index.
checkURLFile();
requests.prepend(method + " " + getRequestURI()+" " +
httpVersion, null);
requests.prepend(requestLine, null);
}
if (!getUseCaches()) {
requests.setIfNotSet ("Cache-Control", "no-cache");
Expand All @@ -656,8 +659,7 @@ private void writeRequests() throws IOException {
* or if keep alive is disabled via a system property
*/

// Try keep-alive only on first attempt
if (!failedOnce && http.getHttpKeepAliveSet()) {
if (http.getHttpKeepAliveSet()) {
if (http.usingProxy && tunnelState() != TunnelState.TUNNELING) {
requests.setIfNotSet("Proxy-Connection", "keep-alive");
} else {
Expand Down

1 comment on commit 50c37f5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.