@@ -73,14 +73,15 @@ protected boolean redirect(Request request, NettyResponseFuture<?> future, HttpR
73
73
URI uri = AsyncHttpProviderUtils .getRedirectUri (future .getURI (), location );
74
74
75
75
if (!uri .toString ().equals (future .getURI ().toString ())) {
76
- final RequestBuilder nBuilder = new RequestBuilder (future .getRequest ());
76
+ final RequestBuilder requestBuilder = new RequestBuilder (future .getRequest ());
77
77
if (config .isRemoveQueryParamOnRedirect ()) {
78
- nBuilder .setQueryParameters (null );
78
+ requestBuilder .setQueryParameters (null );
79
79
}
80
80
81
81
// FIXME why not do that for 301 and 307 too?
82
+ // FIXME I think condition is wrong
82
83
if ((status .equals (FOUND ) || status .equals (SEE_OTHER )) && !(status .equals (FOUND ) && config .isStrict302Handling ())) {
83
- nBuilder .setMethod (HttpMethod .GET .name ());
84
+ requestBuilder .setMethod (HttpMethod .GET .name ());
84
85
}
85
86
86
87
// in case of a redirect from HTTP to HTTPS, future attributes might change
@@ -90,20 +91,20 @@ protected boolean redirect(Request request, NettyResponseFuture<?> future, HttpR
90
91
future .setURI (uri );
91
92
String newUrl = uri .toString ();
92
93
if (request .getUrl ().startsWith (WEBSOCKET )) {
93
- newUrl = newUrl .replace (HTTP , WEBSOCKET );
94
+ newUrl = newUrl .replaceFirst (HTTP , WEBSOCKET );
94
95
}
95
96
96
97
logger .debug ("Redirecting to {}" , newUrl );
97
98
98
99
for (String cookieStr : future .getHttpHeaders ().getAll (HttpHeaders .Names .SET_COOKIE )) {
99
100
for (Cookie c : CookieDecoder .decode (cookieStr )) {
100
- nBuilder .addOrReplaceCookie (c );
101
+ requestBuilder .addOrReplaceCookie (c );
101
102
}
102
103
}
103
104
104
105
for (String cookieStr : future .getHttpHeaders ().getAll (HttpHeaders .Names .SET_COOKIE2 )) {
105
106
for (Cookie c : CookieDecoder .decode (cookieStr )) {
106
- nBuilder .addOrReplaceCookie (c );
107
+ requestBuilder .addOrReplaceCookie (c );
107
108
}
108
109
}
109
110
@@ -125,7 +126,7 @@ public void call() throws Exception {
125
126
callback .call ();
126
127
}
127
128
128
- Request target = nBuilder .setUrl (newUrl ).build ();
129
+ Request target = requestBuilder .setUrl (newUrl ).build ();
129
130
future .setRequest (target );
130
131
// FIXME why not reuse the channel is same host?
131
132
requestSender .sendNextRequest (target , future );
0 commit comments