更新时间:2022-04-19 05:22:57
如果您使用 Apache HttpClient
,您将获得一个java响应对象,可用于提取标头或邮件正文。请考虑以下示例
If you use for instance Apache HttpClient
you will get a java response object which you can use to extract headers or the message body. Consider the following sample
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(new HttpGet("http://www.foo.com/"));
Header[] headers = response.getAllHeaders();
InputStream responseBody = response.getEntity().getContent();
如果您只想解析响应,可能是 HttpMessageParser
将非常有用:
If you only want to parse a reponse, perhaps the HttpMessageParser
will be useful:
抽象消息解析器,用于从任意数据源构建HTTP消息。
Abstract message parser intended to build HTTP messages from an arbitrary data source.