HttpClient 学习记录 (二)

1.message header (header)包含了一些消息头的属性,如:Content length ,content type

下面是同过response 简单获取header:

另外一种获取方式是以迭代器的方式:使用HeaderIterator接口来获取header

提供了一些方便的方法去格式化http消息头,看上去更直观:

HttpEntity:从服务器返回的数据类容,除去头部消息;

Httpclient只能辨别三种Entity:

Streamed:流形势的,一般是从response返回的,这种实体一般不会重复;

self-contained:这种形势的entity 一般在内存中,或是一个独立的连接和entity;并且是可重复的;这种类型通常用在封闭的http requests 中。

wrapping: 一般包裹在其他实体中;

In that case, it is suggested to
consider non-repeatable entities as streamed, and those that are repeatable as self-contained.

在这种情况下,建议
考虑不可重复的实体作为流,和那些可重复的,作为独立的。

一个entity是可重复的,意味着它会被读取超过多次,

This is only possible with
self contained entities (like ByteArrayEntity or StringEntity)

这是唯一的可能当使用self-contained 类型时,例如 ByteArrayEntity(字节数组实体)和StringEntity(字符串实体)

原文地址:https://www.cnblogs.com/TakeaHeader/p/5410904.html