Skip to content

Commit d6e5c15

Browse files
author
Stephane Landelle
committed
Support multi valued headers, close AsyncHttpClient#403
1 parent 221df62 commit d6e5c15

File tree

1 file changed

+11
-14
lines changed
  • providers/netty/src/main/java/org/asynchttpclient/providers/netty/request

1 file changed

+11
-14
lines changed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/request/NettyRequests.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.Map.Entry;
3838

3939
import org.asynchttpclient.AsyncHttpClientConfig;
40-
import org.asynchttpclient.FluentCaseInsensitiveStringsMap;
4140
import org.asynchttpclient.ProxyServer;
4241
import org.asynchttpclient.Realm;
4342
import org.asynchttpclient.Request;
@@ -61,7 +60,7 @@ public static HttpRequest newNettyRequest(AsyncHttpClientConfig config, Request
6160
method = HttpMethod.CONNECT;
6261
else
6362
method = HttpMethod.valueOf(request.getMethod());
64-
63+
6564
String host = null;
6665
HttpVersion httpVersion;
6766
String requestUri;
@@ -107,18 +106,6 @@ else if (uri.getRawQuery() != null)
107106
}
108107

109108
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-
122109
if (config.isCompressionEnabled()) {
123110
headers.put(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);
124111
}
@@ -186,6 +173,7 @@ else if (uri.getRawQuery() != null)
186173
}
187174

188175
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
189177
if (!request.getHeaders().containsKey("Proxy-Connection")) {
190178
headers.put("Proxy-Connection", AsyncHttpProviderUtils.keepAliveHeaderValue(config));
191179
}
@@ -297,6 +285,15 @@ else if (uri.getRawQuery() != null)
297285
} else {
298286
nettyRequest = new DefaultFullHttpRequest(httpVersion, method, requestUri);
299287
}
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
300297
for (Entry<String, Object> header : headers.entrySet()) {
301298
nettyRequest.headers().set(header.getKey(), header.getValue());
302299
}

0 commit comments

Comments
 (0)