Apache Commons HttpConnection:PostMethod - 获取底层的HttpConnection

时间:2013-07-17 07:55:30

标签: java apache connection

我如何获取org.apache.commons.httpclient.methods.PostMethod或org.apache.commons.httpclient.HttpClient对象的底层HttpConnection?

1 个答案:

答案 0 :(得分:0)

如果您有HttpClient的实例,则可以使用此实例获取HttpConnection参考:

    PostMethod post = new PostMethod(url);
    // ...
    HttpClient httpclient = new HttpClient();  
    httpclient.getHttpConnectionManager().getConnection(HostConfiguration.ANY_HOST_CONFIGURATION);
    // ...
    httpclient.executeMethod(post);