Thanks for posting here Moataz, I am busy with other work at the moment, but just to say that providing some level of support for multipart has come up a number of times (it is very useful). The built-in body publishers and subscribers are deliberately minimal, but it does seem that, at least, some level of support to more easy build multipart (if not multipart itself) would be desirable.
-Chris. > On 11 May 2020, at 22:56, Moataz Abdelnasser <moataz.nasse...@gmail.com> > wrote: > > 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