16
16
import static com .ning .http .client .providers .netty .util .HttpUtils .HTTP ;
17
17
import static com .ning .http .client .providers .netty .util .HttpUtils .WEBSOCKET ;
18
18
import static com .ning .http .util .AsyncHttpProviderUtils .followRedirect ;
19
- import static org .jboss .netty .handler .codec .http .HttpResponseStatus .FOUND ;
20
- import static org .jboss .netty .handler .codec .http .HttpResponseStatus .MOVED_PERMANENTLY ;
21
- import static org .jboss .netty .handler .codec .http .HttpResponseStatus .SEE_OTHER ;
22
- import static org .jboss .netty .handler .codec .http .HttpResponseStatus .TEMPORARY_REDIRECT ;
23
19
import static org .jboss .netty .handler .codec .http .HttpHeaders .Names .*;
20
+ import static org .jboss .netty .handler .codec .http .HttpResponseStatus .*;
24
21
25
22
import org .jboss .netty .channel .Channel ;
26
23
import org .jboss .netty .handler .codec .http .HttpHeaders ;
34
31
import com .ning .http .client .HttpResponseHeaders ;
35
32
import com .ning .http .client .HttpResponseStatus ;
36
33
import com .ning .http .client .MaxRedirectException ;
34
+ import com .ning .http .client .Realm ;
35
+ import com .ning .http .client .Realm .AuthScheme ;
37
36
import com .ning .http .client .Request ;
38
37
import com .ning .http .client .RequestBuilder ;
39
38
import com .ning .http .client .cookie .Cookie ;
@@ -91,13 +90,17 @@ public Protocol(ChannelManager channelManager, AsyncHttpClientConfig config, Net
91
90
92
91
public abstract void onClose (NettyResponseFuture <?> future );
93
92
94
- private FluentCaseInsensitiveStringsMap propagatedHeaders (Request request , boolean switchToGet ) {
95
-
93
+ private FluentCaseInsensitiveStringsMap propagatedHeaders (Request request , Realm realm , boolean switchToGet ) {
94
+
96
95
FluentCaseInsensitiveStringsMap originalHeaders = request .getHeaders ();
97
96
originalHeaders .remove (HOST );
98
97
originalHeaders .remove (CONTENT_LENGTH );
99
98
if (switchToGet )
100
99
originalHeaders .remove (CONTENT_TYPE );
100
+ if (realm != null && realm .getScheme () == AuthScheme .NTLM ) {
101
+ originalHeaders .remove (AUTHORIZATION );
102
+ originalHeaders .remove (PROXY_AUTHORIZATION );
103
+ }
101
104
return originalHeaders ;
102
105
}
103
106
@@ -106,7 +109,8 @@ protected boolean exitAfterHandlingRedirect(//
106
109
final NettyResponseFuture <?> future ,//
107
110
HttpResponse response ,//
108
111
Request request ,//
109
- int statusCode ) throws Exception {
112
+ int statusCode ,//
113
+ Realm realm ) throws Exception {
110
114
111
115
if (followRedirect (config , request ) && REDIRECT_STATUSES .contains (statusCode )) {
112
116
if (future .incrementAndGetCurrentRedirectCount () >= config .getMaxRedirects ()) {
@@ -147,7 +151,7 @@ protected boolean exitAfterHandlingRedirect(//
147
151
requestBuilder .addOrReplaceCookie (c );
148
152
}
149
153
150
- requestBuilder .setHeaders (propagatedHeaders (future .getRequest (), switchToGet ));
154
+ requestBuilder .setHeaders (propagatedHeaders (future .getRequest (), realm , switchToGet ));
151
155
152
156
final Request nextRequest = requestBuilder .setUrl (newUrl ).build ();
153
157
0 commit comments