最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【基本解决】HttpParams中的BasicHttpParams vs DefaultedHttpParams以及CoreProtocolPNames中的HTTP_CONTENT_CHARSET vs HTTP_ELEMENT_CHARSET

Java crifan 5112浏览 0评论

【背景】

折腾:

【未解决】java中没法new:Cannot instantiate the type HttpParams

期间,看到:

Interface HttpParams

中,有很多个实现:

AbstractHttpParams, BasicHttpParams, DefaultedHttpParams, SyncBasicHttpParams

但是不知道其具体有何区别,尤其是:

BasicHttpParams vs DefaultedHttpParams

【折腾过程】

1.后来是,看了:

HttpClient 初读–HttpParams 的层级结构

的结构图:

httpclient httpparam hierarchy

才算有点基本明白:

HttpParams是接口interface;

其实现是DefaultHttpParams

然后包含了HttpConnecttionParams(和另外两个:HostParams和HttpMethodParams)

而HttpConnectionManagerParams又是继承HttpConnecttionParams

而HttpClientParams是继承HttpMethodParams

2.至此,另外在:

android Post Get(普通)

中看到的,HttpConnectionParams,也才算有点概念。

3.然后,又去看看其所提到的:

HTTP_CONTENT_CHARSET

结果没发现:

HttpMethodParams.HTTP_CONTENT_CHARSET

后来是去找到了,是在:

Interface CoreProtocolPNames

中有:

static StringHTTP_CONTENT_CHARSET

Defines the charset to be used per default for encoding content body.
static StringHTTP_ELEMENT_CHARSET

Defines the charset to be used for encoding HTTP protocol elements.
static StringHTTP_MALFORMED_INPUT_ACTION

Defines the action to perform upon receiving a malformed input.
static StringHTTP_UNMAPPABLE_INPUT_ACTION

Defines the action to perform upon receiving an unmappable input.
static StringORIGIN_SERVER

Defines the content of the Server header.
static StringPROTOCOL_VERSION

Defines the ProtocolVersion used per default.
static StringSTRICT_TRANSFER_ENCODING

Defines whether responses with an invalid Transfer-Encoding header should be rejected.
static StringUSE_EXPECT_CONTINUE

Activates ‘Expect: 100-Continue’ handshake for the entity enclosing methods.
static StringUSER_AGENT

Defines the content of the User-Agent header.
static StringWAIT_FOR_CONTINUE

Defines the maximum period of time in milliseconds the client should spend waiting for a 100-continue response.

4.对应的,也容易看出:

HTTP_CONTENT_CHARSET vs HTTP_ELEMENT_CHARSET

的话是:

  • HTTP_CONTENT_CHARSET:是指的是html返回的response的body,才是我们常常所关心的,html的charset
  • HTTP_ELEMENT_CHARSET:是指的是,发送http的request时候的charset

 

【总结】

java中的http相关的库的东西和概念,真的够多,很容易搞混。。。

转载请注明:在路上 » 【基本解决】HttpParams中的BasicHttpParams vs DefaultedHttpParams以及CoreProtocolPNames中的HTTP_CONTENT_CHARSET vs HTTP_ELEMENT_CHARSET

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.190 seconds, using 22.12MB memory