Parsing a multi-part response from a http get

时间:2015-04-23 05:40:30

标签: java multipartentity

I'm developing an integration between 2 applications. Application 1 uses HttpClient GetMethod to request from Application 2. Application 2 will return a multipart response with files embedded. I thought this was a simple exercise, but cannot seem to find common support for parsing a multipart response from HTTP GET. How can Application 1 parse the multipart response from Application 2?

3 个答案:

答案 0 :(得分:0)

当您使用多部分编码将请求发送到服务器(Servlet)时。由于多部分编码加密该表单中的所有数据,您必须先解密它们,然后才能使用这些值。

请点击此链接。

What does enctype='multipart/form-data' mean?

Convenient way to parse incoming multipart/form-data parameters in a Servlet

答案 1 :(得分:0)

我也遇到了同样的问题。我用javax邮件MimeMultiPart解决了它。你可以在这里看到我的解决方案: - https://stackoverflow.com/a/42548549/5236494

答案 2 :(得分:0)

对于后人来说,即使HTTP库严重支持这种模式也没有错:

https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

请注意,虽然Content-Type不是multipart/form-data而是multipart/mixed但是部分之间的边界编码几乎相同。