quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Support multipart/mixed in Rest Client Reactive

Open Ballsigno opened this issue 2 years ago • 2 comments

Description

I would be happy If I could send multipart/mixed requests using Rest Client Reactive rather than using Apache HttpClient. Therefore I request this feature!


Discussions: https://github.com/quarkusio/quarkus/discussions/28021 Sample Project (I researched the current status): https://github.com/Ballsigno/quarkus-multipart-mixed-test

Implementation ideas

No response

Ballsigno avatar Sep 17 '22 04:09 Ballsigno

/cc @Sgitario, @cescoffier, @geoand

quarkus-bot[bot] avatar Sep 17 '22 04:09 quarkus-bot[bot]

This seems like a reasonable request to me.

WDYT @cescoffier @Sgitario ?

geoand avatar Sep 19 '22 05:09 geoand

@Ballsigno I am unclear from your reproducer which methods you expect to work. Can you clarify?

geoand avatar Mar 03 '23 15:03 geoand

@geoand I'm sorry, my memory is a bit fuzzy. I just wanted to use "multipart/mixed" like "multipart/form-data".
Those methods are traces of looking for a workaround. This comment is the trigger.

I think the ideal solution would be to use "mixed" like "form-data".

@POST
@Consumes("multipart/mixed") 
@Produces(MediaType.TEXT_PLAIN)
String postMultipartMixed(@MultipartForm MultipartBody data);

Currently, the following errors occur.

Caused by: java.lang.RuntimeException: '@MultipartForm' can only be used on methods annotated with '@Consumes(MediaType.MULTIPART_FORM_DATA)'. Offending method is 'org.test.service.RestService#java.lang.String postMultipartMixed(org.test.model.MultipartBody data)'

Ballsigno avatar Mar 03 '23 16:03 Ballsigno

No problem. I'll look into it

geoand avatar Mar 03 '23 16:03 geoand

I'm not sure this fix is enough.

Regarding the rfc https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html, the multipart/mixed content type can have one parameter. The boundary. The header sended should be like that : Content-Type: multipart/mixed; boundary=MY_BOUNDARY

In fact, this is used with complex body type with nested blocks like in the use case of batch processing for odata https://www.odata.org/documentation/odata-version-3-0/batch-processing/

POST /service/$batch HTTP/1.1 
Host: host 
Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b 

--batch_36522ad7-fc75-4b56-8c71-56071383e77b
Content-Type: application/http 
Content-Transfer-Encoding:binary

GET /service/Customers('ALFKI') 
Host: host

--batch_36522ad7-fc75-4b56-8c71-56071383e77b
Content-Type: multipart/mixed; boundary=changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621
Content-Length: ###       

--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621
Content-Type: application/http 
Content-Transfer-Encoding: binary 

POST /service/Customers HTTP/1.1 
Host: host  
Content-Type: application/atom+xml;type=entry 
Content-Length: ### 

<AtomPub representation of a new Customer> 

--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621 
Content-Type: application/http 
Content-Transfer-Encoding:binary 

PUT /service/Customers('ALFKI') HTTP/1.1 
Host: host 
Content-Type: application/json 
If-Match: xxxxx 
Content-Length: ### 

<JSON representation of Customer ALFKI> 

--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621-- 

--batch_36522ad7-fc75-4b56-8c71-56071383e77b 
Content-Type: application/http 
Content-Transfer-Encoding:binary 

GET service/Products HTTP/1.1 
Host: host 

--batch_36522ad7-fc75-4b56-8c71-56071383e77b--

So I think we should at least be able to specify a boundary.

Maybe it's an enhancement and not an issue.

benDeMtp avatar Mar 08 '23 13:03 benDeMtp

From what I understand, multipart/mixed has been deprecated. If we do need changes, I would very much prefer them to be extremely limited as the client code is way to complex as it is.

The changes would likely need to be in org.jboss.resteasy.reactive.client.impl.multipart.PausableHttpPostRequestEncoder

geoand avatar Mar 08 '23 13:03 geoand