Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
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 */
28 package ch.boye.httpclientandroidlib;
30 import ch.boye.httpclientandroidlib.protocol.HttpContext;
32 /**
33 * Interface for deciding whether a connection can be re-used for
34 * subsequent requests and should be kept alive.
35 * <p>
36 * Implementations of this interface must be thread-safe. Access to shared
37 * data must be synchronized as methods of this interface may be executed
38 * from multiple threads.
39 *
40 * @since 4.0
41 */
42 public interface ConnectionReuseStrategy {
44 /**
45 * Decides whether a connection can be kept open after a request.
46 * If this method returns <code>false</code>, the caller MUST
47 * close the connection to correctly comply with the HTTP protocol.
48 * If it returns <code>true</code>, the caller SHOULD attempt to
49 * keep the connection open for reuse with another request.
50 * <br/>
51 * One can use the HTTP context to retrieve additional objects that
52 * may be relevant for the keep-alive strategy: the actual HTTP
53 * connection, the original HTTP request, target host if known,
54 * number of times the connection has been reused already and so on.
55 * <br/>
56 * If the connection is already closed, <code>false</code> is returned.
57 * The stale connection check MUST NOT be triggered by a
58 * connection reuse strategy.
59 *
60 * @param response
61 * The last response received over that connection.
62 * @param context the context in which the connection is being
63 * used.
64 *
65 * @return <code>true</code> if the connection is allowed to be reused, or
66 * <code>false</code> if it MUST NOT be reused
67 */
68 boolean keepAlive(HttpResponse response, HttpContext context);
70 }