mkopylec / charon-spring-boot-starter

Reverse proxy implementation in form of a Spring Boot starter.
Apache License 2.0
245 stars 55 forks source link

multipart/form-data support ? #39

Closed nortthon closed 5 years ago

nortthon commented 6 years ago

Has anyone reported or is there any solution to traffic multipart/form-data content-type? When I submit this content-type, the following error is displayed: java.io.IOException: UT000036: Connection terminated parsing multipart data

This is because the file gets lost in the proxy. Any solution? Can you help me with this?

Thanks

mkopylec commented 6 years ago

Hi there was an issue about multipart: https://github.com/mkopylec/charon-spring-boot-starter/issues/34 Charon uses RestTemplate to proxy HTTP requests. I haven't tested sending multipart data over the proxy and don't know is there any solution to proxy multipart data without reading the whole part into memory and still use RestTemplate.

Multipart data can definitly be proxied via RestTemplate by reading all the part into memory. But it is probably not supoorted by charon right now.

jecuendet commented 6 years ago

As long as Charon is a Reverse Proxy, it should not know the content of the body. So the request being a multipart should not change the way Charon treat the request/response.

BTW, we have had a problem with multipart/wwwformencoded with Spring (Boot) Filters Spring boot add some filters which read and parse www-form-encoded requests. To decode it, it needs a Charset. If the request doesn't carry one (it's bad but old applications, you know...), Spring forces to the default charset (ISO-8859-1 or UTF-8), then the request can be garbaged. We have resolved this by setting the ReverseProxyFilter very high in the Spring FilterChainProxy chain. Before a filter try to parse the body for wwwdata-form-urlencoded request.

RichardBradley commented 6 years ago

Please could you retest on the current version? There were some problems with Transfer-Encoding: chunked which might have caused this that have been fixed in 2.4.0

RichardBradley commented 6 years ago

As long as Charon is a Reverse Proxy, it should not know the content of the body.

That might be true for a Layer 4 proxy, but Charon acts like a Layer 7 proxy and reads and decodes the whole upstream response body before constructing a entirely new response to the client. If Charon misunderstands the upstream response encoding or format, then the downstream response will be garbled.

mkopylec commented 5 years ago

Is this issue still valid?

mkopylec commented 5 years ago

Closing because of no response. Try 4.0.0 version and check if you still have the problem.