Skip to content

Commit d0bc3fc

Browse files
author
Stephane Landelle
committed
1 parent 2662a46 commit d0bc3fc

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

src/main/java/com/ning/http/client/providers/apache/ApacheResponse.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,16 @@ public FluentCaseInsensitiveStringsMap getHeaders() {
146146
/* @Override */
147147

148148
public boolean isRedirected() {
149-
return (status.getStatusCode() >= 300) && (status.getStatusCode() <= 399);
149+
switch (status.getStatusCode()) {
150+
case 301:
151+
case 302:
152+
case 303:
153+
case 307:
154+
case 308:
155+
return true;
156+
default:
157+
return false;
158+
}
150159
}
151160

152161
/* @Override */

src/main/java/com/ning/http/client/providers/grizzly/GrizzlyResponse.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,16 @@ public FluentCaseInsensitiveStringsMap getHeaders() {
248248
* {@inheritDoc}
249249
*/
250250
public boolean isRedirected() {
251-
252-
return between(status.getStatusCode(), 300, 399);
253-
251+
switch (status.getStatusCode()) {
252+
case 301:
253+
case 302:
254+
case 303:
255+
case 307:
256+
case 308:
257+
return true;
258+
default:
259+
return false;
260+
}
254261
}
255262

256263

@@ -345,14 +352,4 @@ private Charset getCharset(final String charset) {
345352
return Charsets.lookupCharset(charsetLocal);
346353

347354
}
348-
349-
350-
private boolean between(final int value,
351-
final int lowerBound,
352-
final int upperBound) {
353-
354-
return (value >= lowerBound && value <= upperBound);
355-
356-
}
357-
358355
}

src/main/java/com/ning/http/client/providers/jdk/JDKResponse.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,16 @@ public FluentCaseInsensitiveStringsMap getHeaders() {
161161
/* @Override */
162162

163163
public boolean isRedirected() {
164-
return (status.getStatusCode() >= 300) && (status.getStatusCode() <= 399);
164+
switch (status.getStatusCode()) {
165+
case 301:
166+
case 302:
167+
case 303:
168+
case 307:
169+
case 308:
170+
return true;
171+
default:
172+
return false;
173+
}
165174
}
166175

167176
/* @Override */

src/main/java/com/ning/http/client/providers/netty/NettyResponse.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,16 @@ public FluentCaseInsensitiveStringsMap getHeaders() {
170170
/* @Override */
171171

172172
public boolean isRedirected() {
173-
return (status.getStatusCode() >= 300) && (status.getStatusCode() <= 399);
173+
switch (status.getStatusCode()) {
174+
case 301:
175+
case 302:
176+
case 303:
177+
case 307:
178+
case 308:
179+
return true;
180+
default:
181+
return false;
182+
}
174183
}
175184

176185
/* @Override */

0 commit comments

Comments
 (0)