diff --git a/codec-multipart/src/main/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java b/codec-multipart/src/main/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java index 00f5533..da2732b 100644 --- a/codec-multipart/src/main/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java +++ b/codec-multipart/src/main/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java @@ -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 { diff --git a/codec-multipart/src/test/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java b/codec-multipart/src/test/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java index 098cace..4106074 100644 --- a/codec-multipart/src/test/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java +++ b/codec-multipart/src/test/java/io/netty/contrib/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java @@ -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; diff --git a/pom.xml b/pom.xml index bb3e16a..5fd2b6b 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ - 4.1.78.Final + 4.1.80.Final-SNAPSHOT 29 github