Hello,
I'm looking to the goodness of wiremock to mock a multipart/related
RFC-2387 stream. I have noted the following wiremock existing feature request:
Whilst this PR will nobly permit parsing multipart mime (multipart/form or multipart/mixed) content, from some local testing I have conducted it seems this PR cannot readily parse multipart/related RFC-2387 compliant streams ? I get the following stack trace on attempts to test parsing of a multipart/related message:
..
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
... 12 more
Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
at org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:570)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:1052)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:1017)
Has any user encountered similar ? It would seem the current revision of `com.github.tomakehurst.wiremock.http.multipart.PartParser` supports parsing RFC-1876 compliant multipart-form data streams. However, I don't think it covers RFC-2387 compliant multipart/related streams?
In the situation my observations about
multipart/related are correct, perhaps I can offer some ideas/proposals ? Perhaps I could contribute on feature
https://github.com/tomakehurst/wiremock/issues/1047 with some help from the good people here ? I would need guidance/feedback from wiremock author's and main contributor to offer a best solution ?
At a high level my initial proposal would be:
1. Add support for parsing
multipart/related streams (RFC-2387). Possibly leverage existing a parser which supports multipart/related stream parsing ? e.g.
https://github.com/eclipse-ee4j/metro-mimepull I have already tested and confirm this library can parse multipart/related messages.
- Adding such library would add a new compile time dependency to wiremock. Other (more suitable) similar libraries may exist to parse multipart/related messages. Happy to use another if recommendations can be given ? I certainly would suggest to avoid writing mime parsers if an approved one can be vetted. Perhaps someone has alternative ideas ?
2. Update `com.github.tomakehurst.wiremock.http.multipart.PartParser` class to support multipart/related parsing (without impacting legacy behaviour)
3. Add/update unit tests to support the feature update.
I'd be happy to trash out proposal, contribute to a workable solution and to help or independently deliver a PR supporting multipart/related parsing - if that works ?
Please let me know what you think.
Thanks