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

【背景】

折腾:

【未解决】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 String HTTP_CONTENT_CHARSET
Defines the charset to be used per default for encoding content body.
static String HTTP_ELEMENT_CHARSET
Defines the charset to be used for encoding HTTP protocol elements.
static String HTTP_MALFORMED_INPUT_ACTION
Defines the action to perform upon receiving a malformed input.
static String HTTP_UNMAPPABLE_INPUT_ACTION
Defines the action to perform upon receiving an unmappable input.
static String ORIGIN_SERVER
Defines the content of the Server header.
static String PROTOCOL_VERSION
Defines the ProtocolVersion used per default.
static String STRICT_TRANSFER_ENCODING
Defines whether responses with an invalid Transfer-Encoding header should be rejected.
static String USE_EXPECT_CONTINUE
Activates ‘Expect: 100-Continue’ handshake for the entity enclosing methods.
static String USER_AGENT
Defines the content of the User-Agent header.
static String WAIT_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相关的库的东西和概念,真的够多,很容易搞混。。。



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量