Skip to content

Commit 7812e1a

Browse files
author
Julia Boes
committed
8209178: Proxied HttpsURLConnection doesn't send BODY when retrying POST request
Preserve BODY in poster output stream before sending CONNECT request Reviewed-by: bae
1 parent 83fbd1c commit 7812e1a

File tree

2 files changed

+423
-11
lines changed

2 files changed

+423
-11
lines changed

jdk/src/share/classes/sun/net/www/http/HttpClient.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -696,11 +696,7 @@ public boolean parseHTTP(MessageHeader responses, ProgressSource pi, HttpURLConn
696696
} else {
697697
// try once more
698698
openServer();
699-
if (needsTunneling()) {
700-
MessageHeader origRequests = requests;
701-
httpuc.doTunneling();
702-
requests = origRequests;
703-
}
699+
checkTunneling(httpuc);
704700
afterConnect();
705701
writeRequests(requests, poster);
706702
return parseHTTP(responses, pi, httpuc);
@@ -711,6 +707,18 @@ public boolean parseHTTP(MessageHeader responses, ProgressSource pi, HttpURLConn
711707

712708
}
713709

710+
// Check whether tunnel must be open and open it if necessary
711+
// (in the case of HTTPS with proxy)
712+
private void checkTunneling(HttpURLConnection httpuc) throws IOException {
713+
if (needsTunneling()) {
714+
MessageHeader origRequests = requests;
715+
PosterOutputStream origPoster = poster;
716+
httpuc.doTunneling();
717+
requests = origRequests;
718+
poster = origPoster;
719+
}
720+
}
721+
714722
private boolean parseHTTPHeader(MessageHeader responses, ProgressSource pi, HttpURLConnection httpuc)
715723
throws IOException {
716724
/* If "HTTP/*" is found in the beginning, return true. Let
@@ -838,11 +846,7 @@ private boolean parseHTTPHeader(MessageHeader responses, ProgressSource pi, Http
838846
closeServer();
839847
cachedHttpClient = false;
840848
openServer();
841-
if (needsTunneling()) {
842-
MessageHeader origRequests = requests;
843-
httpuc.doTunneling();
844-
requests = origRequests;
845-
}
849+
checkTunneling(httpuc);
846850
afterConnect();
847851
writeRequests(requests, poster);
848852
return parseHTTP(responses, pi, httpuc);

0 commit comments

Comments
 (0)