equal
deleted
inserted
replaced
33 import java.util.List; |
33 import java.util.List; |
34 import java.util.Map; |
34 import java.util.Map; |
35 import java.net.InetSocketAddress; |
35 import java.net.InetSocketAddress; |
36 import java.util.Objects; |
36 import java.util.Objects; |
37 import java.util.concurrent.Flow; |
37 import java.util.concurrent.Flow; |
38 import java.util.function.Predicate; |
38 import java.util.function.BiPredicate; |
39 |
|
40 import jdk.incubator.http.Http1Exchange.Http1BodySubscriber; |
39 import jdk.incubator.http.Http1Exchange.Http1BodySubscriber; |
41 import jdk.incubator.http.internal.common.HttpHeadersImpl; |
40 import jdk.incubator.http.internal.common.HttpHeadersImpl; |
42 import jdk.incubator.http.internal.common.Log; |
41 import jdk.incubator.http.internal.common.Log; |
43 import jdk.incubator.http.internal.common.Utils; |
42 import jdk.incubator.http.internal.common.Utils; |
44 |
43 |
80 String s = completeHeaders.replaceAll("\r\n", "\n"); |
79 String s = completeHeaders.replaceAll("\r\n", "\n"); |
81 Log.logHeaders("REQUEST HEADERS:\n" + s); |
80 Log.logHeaders("REQUEST HEADERS:\n" + s); |
82 } |
81 } |
83 } |
82 } |
84 |
83 |
|
84 |
85 private void collectHeaders0(StringBuilder sb) { |
85 private void collectHeaders0(StringBuilder sb) { |
86 Predicate<String> filter = connection.isTunnel() |
86 BiPredicate<String,List<String>> filter = |
87 ? Utils.NO_PROXY_HEADER : Utils.ALL_HEADERS; |
87 connection.headerFilter(request); |
88 |
88 |
89 // If we're sending this request through a tunnel, |
89 // If we're sending this request through a tunnel, |
90 // then don't send any preemptive proxy-* headers that |
90 // then don't send any preemptive proxy-* headers that |
91 // the authentication filter may have saved in its |
91 // the authentication filter may have saved in its |
92 // cache. |
92 // cache. |
97 // to the target server. |
97 // to the target server. |
98 collectHeaders1(sb, userHeaders, filter); |
98 collectHeaders1(sb, userHeaders, filter); |
99 sb.append("\r\n"); |
99 sb.append("\r\n"); |
100 } |
100 } |
101 |
101 |
102 private void collectHeaders1(StringBuilder sb, HttpHeaders headers, Predicate<String> filter) { |
102 private void collectHeaders1(StringBuilder sb, HttpHeaders headers, |
|
103 BiPredicate<String, List<String>> filter) { |
103 for (Map.Entry<String,List<String>> entry : headers.map().entrySet()) { |
104 for (Map.Entry<String,List<String>> entry : headers.map().entrySet()) { |
104 String key = entry.getKey(); |
105 String key = entry.getKey(); |
105 if (!filter.test(key)) continue; |
|
106 List<String> values = entry.getValue(); |
106 List<String> values = entry.getValue(); |
|
107 if (!filter.test(key, values)) continue; |
107 for (String value : values) { |
108 for (String value : values) { |
108 sb.append(key).append(": ").append(value).append("\r\n"); |
109 sb.append(key).append(": ").append(value).append("\r\n"); |
109 } |
110 } |
110 } |
111 } |
111 } |
112 } |