1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* 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
696
696
} else {
697
697
// try once more
698
698
openServer ();
699
- if (needsTunneling ()) {
700
- MessageHeader origRequests = requests ;
701
- httpuc .doTunneling ();
702
- requests = origRequests ;
703
- }
699
+ checkTunneling (httpuc );
704
700
afterConnect ();
705
701
writeRequests (requests , poster );
706
702
return parseHTTP (responses , pi , httpuc );
@@ -711,6 +707,18 @@ public boolean parseHTTP(MessageHeader responses, ProgressSource pi, HttpURLConn
711
707
712
708
}
713
709
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
+
714
722
private boolean parseHTTPHeader (MessageHeader responses , ProgressSource pi , HttpURLConnection httpuc )
715
723
throws IOException {
716
724
/* If "HTTP/*" is found in the beginning, return true. Let
@@ -838,11 +846,7 @@ private boolean parseHTTPHeader(MessageHeader responses, ProgressSource pi, Http
838
846
closeServer ();
839
847
cachedHttpClient = false ;
840
848
openServer ();
841
- if (needsTunneling ()) {
842
- MessageHeader origRequests = requests ;
843
- httpuc .doTunneling ();
844
- requests = origRequests ;
845
- }
849
+ checkTunneling (httpuc );
846
850
afterConnect ();
847
851
writeRequests (requests , poster );
848
852
return parseHTTP (responses , pi , httpuc );
0 commit comments