mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnection.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

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 java.io.IOException;
    32 /**
    33  * A generic HTTP connection, useful on client and server side.
    34  *
    35  * @since 4.0
    36  */
    37 public interface HttpConnection {
    39     /**
    40      * Closes this connection gracefully.
    41      * This method will attempt to flush the internal output
    42      * buffer prior to closing the underlying socket.
    43      * This method MUST NOT be called from a different thread to force
    44      * shutdown of the connection. Use {@link #shutdown shutdown} instead.
    45      */
    46     public void close() throws IOException;
    48     /**
    49      * Checks if this connection is open.
    50      * @return true if it is open, false if it is closed.
    51      */
    52     public boolean isOpen();
    54     /**
    55      * Checks whether this connection has gone down.
    56      * Network connections may get closed during some time of inactivity
    57      * for several reasons. The next time a read is attempted on such a
    58      * connection it will throw an IOException.
    59      * This method tries to alleviate this inconvenience by trying to
    60      * find out if a connection is still usable. Implementations may do
    61      * that by attempting a read with a very small timeout. Thus this
    62      * method may block for a small amount of time before returning a result.
    63      * It is therefore an <i>expensive</i> operation.
    64      *
    65      * @return  <code>true</code> if attempts to use this connection are
    66      *          likely to succeed, or <code>false</code> if they are likely
    67      *          to fail and this connection should be closed
    68      */
    69     public boolean isStale();
    71     /**
    72      * Sets the socket timeout value.
    73      *
    74      * @param timeout timeout value in milliseconds
    75      */
    76     void setSocketTimeout(int timeout);
    78     /**
    79      * Returns the socket timeout value.
    80      *
    81      * @return positive value in milliseconds if a timeout is set,
    82      * <code>0</code> if timeout is disabled or <code>-1</code> if
    83      * timeout is undefined.
    84      */
    85     int getSocketTimeout();
    87     /**
    88      * Force-closes this connection.
    89      * This is the only method of a connection which may be called
    90      * from a different thread to terminate the connection.
    91      * This method will not attempt to flush the transmitter's
    92      * internal buffer prior to closing the underlying socket.
    93      */
    94     public void shutdown() throws IOException;
    96     /**
    97      * Returns a collection of connection metrics.
    98      *
    99      * @return HttpConnectionMetrics
   100      */
   101     HttpConnectionMetrics getMetrics();
   103 }

mercurial