4

我的任务是实现发送 http 多部分请求并解释 http 多部分响应。我决定从响应开始,因为我只需要接收响应并解析它。我对 java 的经验并不多,对 HTTP 的经验更少,这就是为什么我阅读了一些关于该主题的文章和其他内容,但我仍然有一些悬而未决的问题:

  1. 据我了解,内容类型 multipart 用于文件上传、发送电子邮件附件等。我在 google 中找到的大多数帖子实际上都是使用 multipart/form-data 进行文件上传的。在哪些其他情况下使用此内容类型?
  2. 我决定从 HTTP 多部分响应开始,但我意识到我不知道我必须做什么才能接收具有这种内容类型的响应。我的请求应该是什么样子,我应该对这个请求提出什么要求?我只想用java编写一个简单的程序,它向服务器发送一个HTTP请求,接收到的响应是内容类型的多部分。

如果有人可以向我澄清这些事情会很好,因为我认为我误解了一些东西。

先感谢您!

4

1 回答 1

7

I would recommend turning to Apache Commons:

  • FileUpload handles the server-side, and parses multi-part posts.
  • HttpClient for the client-side, for constructing those posts.

But before you do any of that, I think you need to talk with whoever has set you on this task, to be sure that you understand exactly what he/she wants. Because multi-part for mail processing is close but not quite the same as multipart for file uploads.

于 2011-01-04T18:15:12.900 回答