• 大小: 3.29MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-09
  • 语言: Java
  • 标签: HTTP状态  

资源简介

提供了可重用的客户端验证、HTTP状态管理、HTTP连接管理组件,简化HTTP客户端和服务器进行各种通信编程。

资源截图

代码片段和文件信息

/*
 * ====================================================================
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License Version 2.0 (the
 * “License“); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing
 * software distributed under the License is distributed on an
 * “AS IS“ BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation please see
 * .
 *
 */

package org.apache.http.examples.client;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

/**
 * This example demonstrates how to abort an HTTP method before its normal completion.
 */
public class ClientAbortMethod {

    public final static void main(String[] args) throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpget = new HttpGet(“http://www.apache.org/“);

            System.out.println(“executing request “ + httpget.getURI());
            HttpResponse response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();

            System.out.println(“----------------------------------------“);
            System.out.println(response.getStatusLine());
            if (entity != null) {
                System.out.println(“Response content length: “ + entity.getContentLength());
            }
            System.out.println(“----------------------------------------“);

            // Do not feel like reading the response body
            // Call abort on the request object
            httpget.abort();
        } finally {
            // When HttpClient instance is no longer needed
            // shut down the connection manager to ensure
            // immediate deallocation of all system resources
            httpclient.getConnectionManager().shutdown();
        }
    }

}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-04-14 20:12  httpcomponents\
     文件       10173  2013-04-20 00:17  httpcomponents\LICENSE.txt
     文件         183  2013-04-20 00:17  httpcomponents\NOTICE.txt
     文件        2627  2013-04-20 00:17  httpcomponents\README.txt
     文件       62170  2019-04-14 20:13  httpcomponents\RELEASE_NOTES.txt
     目录           0  2019-04-14 20:12  httpcomponents\examples\
     目录           0  2019-04-14 20:12  httpcomponents\examples\org\
     目录           0  2019-04-14 20:12  httpcomponents\examples\org\apache\
     目录           0  2019-04-14 20:12  httpcomponents\examples\org\apache\http\
     目录           0  2019-04-14 20:12  httpcomponents\examples\org\apache\http\examples\
     目录           0  2019-04-14 20:12  httpcomponents\examples\org\apache\http\examples\client\
     文件        2740  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientAbortMethod.java
     文件        2921  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientAuthentication.java
     文件        3640  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientChunkEncodedPost.java
     文件        3770  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientConnectionRelease.java
     文件        3680  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientCustomContext.java
     文件        3363  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientCustomSSL.java
     文件        4870  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientEvictExpiredConnections.java
     文件        2877  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientExecuteDirect.java
     文件        3102  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientExecuteProxy.java
     文件        5760  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientExecuteSOCKS.java
     文件        4182  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientFormLogin.java
     文件        5472  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientGZipContentCompression.java
     文件        5318  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientInteractiveAuthentication.java
     文件        6693  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientKerberosAuthentication.java
     文件        4820  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientMultiThreadedExecution.java
     文件        4089  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientPreemptiveBasicAuthentication.java
     文件        4356  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientPreemptiveDigestAuthentication.java
     文件        3361  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientProxyAuthentication.java
     文件        2653  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ClientWithResponseHandler.java
     文件        2835  2013-04-20 00:17  httpcomponents\examples\org\apache\http\examples\client\ProxyTunnelDemo.java
............此处省略883个文件信息

评论

共有 条评论

相关资源