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