8235761: (httpclient) Investigate support for multipart/form-data in BodyPublishers
Moataz Abdelnasser
moataz.nasser20 at gmail.com
Mon May 11 21:56:54 UTC 2020
Email was unintentionally sent in HTML, causing it to be scrubbed.
This is plain text form:
Hi all!
I tackled with the multipart issue in a library I wrote that provides
extensions to the HTTP client including multipart
support (please see https://github.com/mizosoft/methanol). I was
wondering if I could provide a patch for this issue in
the light of https://github.com/mizosoft/methanol/blob/master/methanol/src/main/java/com/github/mizosoft/methanol/MultipartBodyPublisher.java
to be included in java.net.http. Flow control can be rewritten against
the module using jdk.internal.net.http.common.SequentialScheduler.
I haven’t found any of the available RequestPublishers impls that can
be efficiently reused for such flow control.
If that is possible, please consider if I could also provide other
complementary patches such as:
- FormBodyPublisher (similarly in the light of
https://github.com/mizosoft/methanol/blob/master/methanol/src/main/java/com/github/mizosoft/methanol/FormBodyPublisher.java).
This implements the application/x-www-form-urlencoded format. As
with the linked class, this can make use of the already
available jdk.internal.net.http.RequestPublishers.StringPublisher.
- Add an internal trusted MimeBodyPublisher interface that attaches
the correct media type info to the body:
public interface MimeBodyPublisher extends BodyPublisher {
String contentType();
}
The HttpClient can use that to transparently add a Content-Type header
for the request. In case of MultipartBodyPublisher,
this ensures a Content-Type header with the correct boundary (which
might be randomly generated) is used instead of being
explicitly specified by the user. Similarly, this ensures the correct
Content-Type is used in case of FormBodyPublisher.
Please tell me which patches I can start working on. If any, this will
be my first contribution so I believe I will need a sponsor.
Thanks in advance!
Moataz
More information about the net-dev
mailing list