1/*
2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java $
3 * $Revision: 639600 $
4 * $Date: 2008-03-21 04:28:15 -0700 (Fri, 21 Mar 2008) $
5 *
6 * ====================================================================
7 * Licensed to the Apache Software Foundation (ASF) under one
8 * or more contributor license agreements.  See the NOTICE file
9 * distributed with this work for additional information
10 * regarding copyright ownership.  The ASF licenses this file
11 * to you under the Apache License, Version 2.0 (the
12 * "License"); you may not use this file except in compliance
13 * with the License.  You may obtain a copy of the License at
14 *
15 *   http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing,
18 * software distributed under the License is distributed on an
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 * KIND, either express or implied.  See the License for the
21 * specific language governing permissions and limitations
22 * under the License.
23 * ====================================================================
24 *
25 * This software consists of voluntary contributions made by many
26 * individuals on behalf of the Apache Software Foundation.  For more
27 * information on the Apache Software Foundation, please see
28 * <http://www.apache.org/>.
29 *
30 */
31
32package org.apache.http.client.methods;
33
34import java.io.IOException;
35
36import org.apache.http.client.HttpClient;
37import org.apache.http.conn.ClientConnectionManager;
38import org.apache.http.conn.ClientConnectionRequest;
39import org.apache.http.conn.ConnectionReleaseTrigger;
40import org.apache.http.conn.ManagedClientConnection;
41import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
42
43/**
44 * Interface representing an HTTP request that can be aborted by shutting
45 * down the underlying HTTP connection.
46 *
47 * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
48 *
49 * <!-- empty lines to avoid svn diff problems -->
50 * @version   $Revision: 639600 $
51 *
52 * @since 4.0
53 */
54public interface AbortableHttpRequest {
55
56    /**
57     * Sets the {@link ClientConnectionRequest} callback that can be
58     * used to abort a long-lived request for a connection.
59     * If the request is already aborted, throws an {@link IOException}.
60     *
61     * @see ClientConnectionManager
62     * @see ThreadSafeClientConnManager
63     */
64    void setConnectionRequest(ClientConnectionRequest connRequest) throws IOException;
65
66    /**
67     * Sets the {@link ConnectionReleaseTrigger} callback that can
68     * be used to abort an active connection.
69     * Typically, this will be the {@link ManagedClientConnection} itself.
70     * If the request is already aborted, throws an {@link IOException}.
71     */
72    void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
73
74    /**
75     * Aborts this http request. Any active execution of this method should
76     * return immediately. If the request has not started, it will abort after
77     * the next execution. Aborting this request will cause all subsequent
78     * executions with this request to fail.
79     *
80     * @see HttpClient#execute(HttpUriRequest)
81     * @see HttpClient#execute(org.apache.http.HttpHost,
82     *      org.apache.http.HttpRequest)
83     * @see HttpClient#execute(HttpUriRequest,
84     *      org.apache.http.protocol.HttpContext)
85     * @see HttpClient#execute(org.apache.http.HttpHost,
86     *      org.apache.http.HttpRequest, org.apache.http.protocol.HttpContext)
87     */
88    void abort();
89
90}
91
92