Remove unnecessary 'return's / Clean up QueryStringDecoder
This commit is contained in:
parent
a76cdc26d0
commit
4cd7fb1abb
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
@ -25,8 +27,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
/**
|
||||
* Splits an HTTP query string into a path string and key-value parameter pairs.
|
||||
* This decoder is for one time use only. Create a new instance for each URI:
|
||||
@ -235,7 +235,7 @@ public class QueryStringDecoder {
|
||||
String name = null;
|
||||
int pos = 0; // Beginning of the unprocessed region
|
||||
int i; // End of the unprocessed region
|
||||
char c = 0; // Current character
|
||||
char c; // Current character
|
||||
for (i = 0; i < s.length(); i++) {
|
||||
c = s.charAt(i);
|
||||
if (c == '=' && name == null) {
|
||||
@ -263,18 +263,12 @@ public class QueryStringDecoder {
|
||||
|
||||
if (pos != i) { // Are there characters we haven't dealt with?
|
||||
if (name == null) { // Yes and we haven't seen any `='.
|
||||
if (!addParam(params, decodeComponent(s.substring(pos, i), charset), "")) {
|
||||
return;
|
||||
}
|
||||
addParam(params, decodeComponent(s.substring(pos, i), charset), "");
|
||||
} else { // Yes and this must be the last value.
|
||||
if (!addParam(params, name, decodeComponent(s.substring(pos, i), charset))) {
|
||||
return;
|
||||
}
|
||||
addParam(params, name, decodeComponent(s.substring(pos, i), charset));
|
||||
}
|
||||
} else if (name != null) { // Have we seen a name without value?
|
||||
if (!addParam(params, name, "")) {
|
||||
return;
|
||||
}
|
||||
addParam(params, name, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,7 +363,9 @@ public class QueryStringDecoder {
|
||||
if (c == '%') {
|
||||
buf[pos++] = '%'; // "%%" -> "%"
|
||||
break;
|
||||
} else if (i == size - 1) {
|
||||
}
|
||||
|
||||
if (i == size - 1) {
|
||||
throw new IllegalArgumentException("partial escape"
|
||||
+ " sequence at end of string: " + s);
|
||||
}
|
||||
@ -391,7 +387,7 @@ public class QueryStringDecoder {
|
||||
try {
|
||||
return new String(buf, 0, pos, charset.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalArgumentException("unsupported encoding: " + charset.name());
|
||||
throw new IllegalArgumentException("unsupported encoding: " + charset.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user