0
我該如何去獲取org.apache.commons.httpclient.methods.PostMethod或org.apache.commons.httpclient.HttpClient對象的基礎HttpConnection?Apache Commons HttpConnection:PostMethod - 獲取基礎HttpConnection
我該如何去獲取org.apache.commons.httpclient.methods.PostMethod或org.apache.commons.httpclient.HttpClient對象的基礎HttpConnection?Apache Commons HttpConnection:PostMethod - 獲取基礎HttpConnection
如果你有HttpClient
一個實例可以使用此獲得HttpConnection
參考:
PostMethod post = new PostMethod(url);
// ...
HttpClient httpclient = new HttpClient();
httpclient.getHttpConnectionManager().getConnection(HostConfiguration.ANY_HOST_CONFIGURATION);
// ...
httpclient.executeMethod(post);
爲什麼? HttpConnection是流讀取器的抽象,是否有任何方法可供您捕獲輸入/輸出流? –
@BryanAbrams我試圖關閉從HttpConnection但不是PostMethod或HttpClient可能的陳舊連接。 – cxdf