On Sat, 2019-04-13 at 10:03 -0500, Norman Walsh wrote: > Hi, > > I recently upgraded from an earlier version of httpclient where I was > able to construct multipart messages “by hand”. However, the recent > refinements added to check the content type of my message now cause > that approach to fail. (The presence of the “; boundary=…” in the > content type string runs afoul of the syntax checking on the header.) > > The messages that I’m trying to construct have nothing to do with > forms. My requirements appear (to me) to be simple: I want to > construct the multipart message, providing both text and binary > bodies, > with my own headers for each part. > > It seems that the MultipartEntityBuilder is the preferred mechanism > for constructing multipart messages > > > https://hc.apache.org/httpcomponents-client-ga/httpmime/apidocs/index.html > > But, AFAICT: > > 1. The convenience methods (addBinaryBody, addTextBody) provide no > way > to specify headers. > > 2. The ContentBody objects don’t provide any way to specify headers. > > 3. And, while the FormBodyPartBuilder does (in the addField method, > which seems slightly oddly named for this purpose), it also adds a > filename header because its form related. > > Have I overlooked something obvious?
Hi Norman No, you have not. MultipartEntityBuilder generates only minimal set of standard headers. For something more flexible you might want to use Apache Mime4J https://james.apache.org/mime4j/ Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
