Search code examples
httpnettymultipartform-datamultipart

multipart/mixed support in Netty


By browsing the source code and playing with some toy examples I got to the conclusion that Netty currently (as of 5.0.0 alpha2) supports only multipart/form-data, but not multipart/mixed, at least not as specified in RFC1342 (sec. 7.2). It looks like mixed is supported inside a part in multipart/form-data though.

Is that really the case or am I missing something?


Solution

  • Since I get the very same question, I post here what could be an beginning of answear...

    However, the current implementation seems to have 2 limitations:

    1) it supports only multipart/form-data. I would like to also be able to use multipart/mixed, which is very similar on the wire (see http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html ). I think that the encoder/decoder could be extended to understand multipart/mixed and still create the same kinds of HttpDatas.

    Yes, the current codec is focused on multipart/form-data. I shall be possible to extend or propose a new one (based on it probably) to enable the support of multipart/mixed. The current codec was made based on user needs (mine in the beginning, others following). Since no one yet has requested a support for multipart/mixed, it was not coded, except for internal multipart/mixed code. The reference is RFC1867.

    As Netty loves contributions, you are more than welcome to propose yours ;-)

    2) it seems that is it only possible to use efficient HttpDatas like FileUpload if you are in multipart/form-data. I would like to be able to add a FileUpload to the request, and by this way make the contents of the file be the body of the request, without making it a multipart request. I think this could be done by extending the Standard Post Encoder to understand FileUploads.

    This could a bit more complicated since it has to be done without multipart, which holds currently the FileUpload class.

    Maybe a good direction could be to switch to ChunkFile or ChunkNioFile and to combine it with "your" HttpCodec or in your "HttpHandler" when doing the body request, in order to pass the content through the ChunkFile.

    Hoping this helps you in the right direction...