37
37
import java .util .Map .Entry ;
38
38
39
39
import org .asynchttpclient .AsyncHttpClientConfig ;
40
- import org .asynchttpclient .FluentCaseInsensitiveStringsMap ;
41
40
import org .asynchttpclient .ProxyServer ;
42
41
import org .asynchttpclient .Realm ;
43
42
import org .asynchttpclient .Request ;
@@ -61,7 +60,7 @@ public static HttpRequest newNettyRequest(AsyncHttpClientConfig config, Request
61
60
method = HttpMethod .CONNECT ;
62
61
else
63
62
method = HttpMethod .valueOf (request .getMethod ());
64
-
63
+
65
64
String host = null ;
66
65
HttpVersion httpVersion ;
67
66
String requestUri ;
@@ -107,18 +106,6 @@ else if (uri.getRawQuery() != null)
107
106
}
108
107
109
108
if (method != HttpMethod .CONNECT ) {
110
- FluentCaseInsensitiveStringsMap h = request .getHeaders ();
111
- if (h != null ) {
112
- for (Entry <String , List <String >> header : h ) {
113
- String name = header .getKey ();
114
- if (!HttpHeaders .Names .HOST .equalsIgnoreCase (name )) {
115
- for (String value : header .getValue ()) {
116
- headers .put (name , value );
117
- }
118
- }
119
- }
120
- }
121
-
122
109
if (config .isCompressionEnabled ()) {
123
110
headers .put (HttpHeaders .Names .ACCEPT_ENCODING , HttpHeaders .Values .GZIP );
124
111
}
@@ -186,6 +173,7 @@ else if (uri.getRawQuery() != null)
186
173
}
187
174
188
175
if (proxyServer != null ) {
176
+ // FIXME Wikipedia says that Proxy-Connection was a misunderstanding of Connection http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
189
177
if (!request .getHeaders ().containsKey ("Proxy-Connection" )) {
190
178
headers .put ("Proxy-Connection" , AsyncHttpProviderUtils .keepAliveHeaderValue (config ));
191
179
}
@@ -297,6 +285,15 @@ else if (uri.getRawQuery() != null)
297
285
} else {
298
286
nettyRequest = new DefaultFullHttpRequest (httpVersion , method , requestUri );
299
287
}
288
+
289
+ // assign headers as configured on request
290
+ if (method != HttpMethod .CONNECT ) {
291
+ for (Entry <String , List <String >> header : request .getHeaders ()) {
292
+ nettyRequest .headers ().set (header .getKey (), header .getValue ());
293
+ }
294
+ }
295
+
296
+ // override with computed ones
300
297
for (Entry <String , Object > header : headers .entrySet ()) {
301
298
nettyRequest .headers ().set (header .getKey (), header .getValue ());
302
299
}
0 commit comments