Improvement : allocate less object during multipart form parsing.
This commit is contained in:
parent
d21f2adb98
commit
a45f9d7939
@ -764,12 +764,12 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i < contents.length; i++) {
|
for (int i = 1; i < contents.length; i++) {
|
||||||
if (contents[i].toLowerCase().startsWith(HttpHeaderValues.CHARSET.toString())) {
|
final String charsetHeader = HttpHeaderValues.CHARSET.toString();
|
||||||
|
if (contents[i].regionMatches(true, 0, charsetHeader, 0, charsetHeader.length())) {
|
||||||
String values = StringUtil.substringAfter(contents[i], '=');
|
String values = StringUtil.substringAfter(contents[i], '=');
|
||||||
Attribute attribute;
|
Attribute attribute;
|
||||||
try {
|
try {
|
||||||
attribute = factory.createAttribute(request, HttpHeaderValues.CHARSET.toString(),
|
attribute = factory.createAttribute(request, charsetHeader, cleanString(values));
|
||||||
cleanString(values));
|
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new ErrorDataDecoderException(e);
|
throw new ErrorDataDecoderException(e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -155,16 +155,15 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
|||||||
protected static String[] getMultipartDataBoundary(String contentType) {
|
protected static String[] getMultipartDataBoundary(String contentType) {
|
||||||
// Check if Post using "multipart/form-data; boundary=--89421926422648 [; charset=xxx]"
|
// Check if Post using "multipart/form-data; boundary=--89421926422648 [; charset=xxx]"
|
||||||
String[] headerContentType = splitHeaderContentType(contentType);
|
String[] headerContentType = splitHeaderContentType(contentType);
|
||||||
if (headerContentType[0].toLowerCase().startsWith(
|
final String multiPartHeader = HttpHeaderValues.MULTIPART_FORM_DATA.toString();
|
||||||
HttpHeaderValues.MULTIPART_FORM_DATA.toString())) {
|
if (headerContentType[0].regionMatches(true, 0, multiPartHeader, 0 , multiPartHeader.length())) {
|
||||||
int mrank;
|
int mrank;
|
||||||
int crank;
|
int crank;
|
||||||
if (headerContentType[1].toLowerCase().startsWith(
|
final String boundaryHeader = HttpHeaderValues.BOUNDARY.toString();
|
||||||
HttpHeaderValues.BOUNDARY.toString())) {
|
if (headerContentType[1].regionMatches(true, 0, boundaryHeader, 0, boundaryHeader.length())) {
|
||||||
mrank = 1;
|
mrank = 1;
|
||||||
crank = 2;
|
crank = 2;
|
||||||
} else if (headerContentType[2].toLowerCase().startsWith(
|
} else if (headerContentType[2].regionMatches(true, 0, boundaryHeader, 0, boundaryHeader.length())) {
|
||||||
HttpHeaderValues.BOUNDARY.toString())) {
|
|
||||||
mrank = 2;
|
mrank = 2;
|
||||||
crank = 1;
|
crank = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -181,8 +180,8 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
|||||||
boundary = bound.substring(1, index);
|
boundary = bound.substring(1, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (headerContentType[crank].toLowerCase().startsWith(
|
final String charsetHeader = HttpHeaderValues.CHARSET.toString();
|
||||||
HttpHeaderValues.CHARSET.toString())) {
|
if (headerContentType[crank].regionMatches(true, 0, charsetHeader, 0, charsetHeader.length())) {
|
||||||
String charset = StringUtil.substringAfter(headerContentType[crank], '=');
|
String charset = StringUtil.substringAfter(headerContentType[crank], '=');
|
||||||
if (charset != null) {
|
if (charset != null) {
|
||||||
return new String[] {"--" + boundary, charset};
|
return new String[] {"--" + boundary, charset};
|
||||||
|
Loading…
Reference in New Issue
Block a user