Skip to content

Commit

Permalink
Align original copy of netty-4.1.78.Final with latest netty-4.1.80.Fi…
Browse files Browse the repository at this point in the history
…nal-SNAPSHOT in order to get #12664
  • Loading branch information
pderop committed Aug 11, 2022
1 parent d8e42fb commit 29e9111
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,18 @@ private InterfaceHttpData findMultipartDisposition() {
throw new ErrorDataDecoderException(e);
}
currentFieldAttributes.put(HttpHeaderValues.CHARSET, attribute);
} else if (contents[i].contains("=")) {
String name = StringUtil.substringBefore(contents[i], '=');
String values = StringUtil.substringAfter(contents[i], '=');
Attribute attribute;
try {
attribute = factory.createAttribute(request, cleanString(name), values);
} catch (NullPointerException e) {
throw new ErrorDataDecoderException(e);
} catch (IllegalArgumentException e) {
throw new ErrorDataDecoderException(e);
}
currentFieldAttributes.put(name, attribute);
} else {
Attribute attribute;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,25 @@ public void testNotBadReleaseBuffersDuringDecodingMixedFactory() throws IOExcept
commonNotBadReleaseBuffersDuringDecoding(factory, false);
}

@Test
public void testDecodeFullHttpRequestWithOptionalParameters() {
String content = "\n--861fbeab-cd20-470c-9609-d40a0f704466\r\n" +
"content-disposition: form-data; " +
"name=\"file\"; filename=\"myfile.ogg\"\r\n" +
"content-type: audio/ogg; codecs=opus; charset=UTF8\r\ncontent-transfer-encoding: binary\r\n" +
"\r\n\u0001\u0002\u0003\u0004\r\n--861fbeab-cd20-470c-9609-d40a0f704466--\r\n\",\n";

FullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload",
Unpooled.copiedBuffer(content, CharsetUtil.US_ASCII));
req.headers().set("content-type", "multipart/form-data; boundary=861fbeab-cd20-470c-9609-d40a0f704466");
req.headers().set("content-length", content.length());

HttpPostMultipartRequestDecoder test = new HttpPostMultipartRequestDecoder(req);
FileUpload httpData = (FileUpload) test.getBodyHttpDatas("file").get(0);
assertEquals("audio/ogg", httpData.getContentType());
test.destroy();
}

private static void commonNotBadReleaseBuffersDuringDecoding(HttpDataFactory factory, boolean inMemory)
throws IOException {
int nbItems = 20;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</developers>

<properties>
<netty.version>4.1.78.Final</netty.version>
<netty.version>4.1.80.Final-SNAPSHOT</netty.version>
<netty.build.version>29</netty.build.version>
<project.scm.id>github</project.scm.id>
<release.gpg.keyname />
Expand Down

0 comments on commit 29e9111

Please sign in to comment.