標籤:
--httpmime-4.2.5.jar 跟提交Form相關的類
這一塊主要post資料的提交。每一條資料同name和content組成。content可能是位元組數組或是流。提交這一類(MIME)的資料的時候,還要添加一些
header資料。於是FormBodyPart類就誕生了,它的屬性有name,header,content。很多個FormBodyPart組成了HttpMultipart(因為HttpMultipart
有個FormBodyPart的List集合)。所有的東東最後在MultipartEntity中封裝。
org.apache.http.entity.mime包下
AbstractContentBody->ContentBody->ContentDescriptor 其它的類都是AbstractContentBody的子類了。
包括ByteArrayBody、FileBody、InputStreamBody、StringBody。 2014-6-6
--fluent-hc-4.2.5.jar 運行線程執行訪問
核心類Executor 可以設定驗證auth()
這個類也算是一個袖珍型Client了。可以看到這個架構的一個基本架構。比如通過localContext.setAttribute("http.cookie-store", cookieStore);傳入
cookie對象。
協議的註冊:
SchemeRegistry schemeRegistry = new SchemeRegistry();
org.apache.http.conn.scheme.SchemeSocketFactory plain = PlainSocketFactory.getSocketFactory();
schemeRegistry.register(new Scheme("http", 80, plain));
--httpclient-4.2.5.jar
org.apache.http.auth 認證
【英文學習:challenge詢問】
AuthScheme認證協議或稱認證模式
Credentials認證介面,它有兩個實作類別NTCredentials和UsernamePasswordCredentials
想繼續瞭解,可以點這個連結 http://www.cnblogs.com/huqingyu/archive/2008/02/17/1071649.html
org.apache.http.client
這裡主要是定義了一些異常類和介面。介面編程確實有它強大過人之處。
org.apache.http.client.entity http實體物件。http實體想像成容納http資料的類。
HttpEntity介面。http實體都實體了它。包括DecompressingEntity、DeflateStream、GzipDecompressingEntity、UrlEncodedFormEntity。
# org.apache.http.client.methods
AbortableHttpRequest介面,實現它的類具有中斷串連(訪問)的功能
HttpUriRequest介面,實現了uri功能。
以HttpRequestBase為主類,其它的類直接或間接是它的子類。
HttpEntityEnclosingRequestBase是HttpRequestBase的子類。
# org.apache.http.client.params 參數的定義和設定
# org.apache.http.client.protocol
ClientContext介面,定義了一些對象的key,比如scheme-registry協議註冊器,cookie相關對象,認證相關對象還有代理proxy
ClientContextConfigurer類,儲存客戶機配置資料,不過我覺得它裡面的方法是直接取"http.cookiespec-registry"的字串,是不是取它實現的介面ClientContext裡面的常量更合理些呢??
這個包裡面的很多類都是HttpRequestInterceptor的子類。這是個攔截器,它的攔截方法是process(HttpRequest request, HttpContext context)。
這些攔截器的基本工作就是從context中取出相關的設定物件進行處理,把相關資訊放到request的header裡面去。
| RequestAcceptEncoding |
接受的編碼集 |
| RequestAddCookies |
加入cookie |
| RequestAuthCache |
加入認證 |
| RequestAuthenticationBase |
認證的基類 |
| RequestClientConnControl |
串連控制 |
| RequestDefaultHeaders |
加入預設的要求標頭 |
| RequestProxyAuthentication |
代理認證,繼承自RequestAuthenticationBase |
| RequestTargetAuthentication |
目標主機認證,繼承自RequestAuthenticationBase |
最後剩下3個response攔截器(HttpResponseInterceptor),實現的主要功能是,對cookie的儲存,和對各種壓縮流的解壓工作。
| ResponseAuthCache |
這個不推薦用了,不說了 |
| ResponseContentEncoding |
對gzip和deflate格式的流解壓 |
| ResponseProcessCookies |
儲存cookie |
# org.apache.http.client.utils
CloneUtils 複製類,它是通過反射調用了一個對象自身的clone方法。好像不怎麼實用。
HttpClientUtils 關閉response流,關閉client串連。
Idn介面 對字串進行Unicode編碼。
JdkIdn Idn的實作類別
Rfc3492Idn Idn的實作類別
Punycode 對上面兩個實作類別的封裝,如果第一個類用不上,就使用第二個。
還有3個URI處理類URIBuilder、URIUtils、URLEncodedUtils
# org.apache.http.conn
這個包裡多是介面和異常,不太明白,草草看了下。
# org.apache.http.conn.params
這個包好多類都不推薦了。
# org.apache.http.conn.routing
關於路由的包
# org.apache.http.conn.scheme
PlainSocketFactory 簡單socket工廠
Scheme 協議http或是https什麼的
SchemeRegistry 協議註冊器,有個map存Scheme
--httpcore-4.2.4.jar
【英文學習:Catalog 目錄,集合,收錄】
處理gzip流
String body = EntityUtils.toString(new GzipDecompressingEntity(res.getEntity()));
httpclient學習(原創)