1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnection.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* 1.5 + * ==================================================================== 1.6 + * Licensed to the Apache Software Foundation (ASF) under one 1.7 + * or more contributor license agreements. See the NOTICE file 1.8 + * distributed with this work for additional information 1.9 + * regarding copyright ownership. The ASF licenses this file 1.10 + * to you under the Apache License, Version 2.0 (the 1.11 + * "License"); you may not use this file except in compliance 1.12 + * with the License. You may obtain a copy of the License at 1.13 + * 1.14 + * http://www.apache.org/licenses/LICENSE-2.0 1.15 + * 1.16 + * Unless required by applicable law or agreed to in writing, 1.17 + * software distributed under the License is distributed on an 1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1.19 + * KIND, either express or implied. See the License for the 1.20 + * specific language governing permissions and limitations 1.21 + * under the License. 1.22 + * ==================================================================== 1.23 + * 1.24 + * This software consists of voluntary contributions made by many 1.25 + * individuals on behalf of the Apache Software Foundation. For more 1.26 + * information on the Apache Software Foundation, please see 1.27 + * <http://www.apache.org/>. 1.28 + * 1.29 + */ 1.30 + 1.31 +package ch.boye.httpclientandroidlib; 1.32 + 1.33 +import java.io.IOException; 1.34 + 1.35 +/** 1.36 + * A generic HTTP connection, useful on client and server side. 1.37 + * 1.38 + * @since 4.0 1.39 + */ 1.40 +public interface HttpConnection { 1.41 + 1.42 + /** 1.43 + * Closes this connection gracefully. 1.44 + * This method will attempt to flush the internal output 1.45 + * buffer prior to closing the underlying socket. 1.46 + * This method MUST NOT be called from a different thread to force 1.47 + * shutdown of the connection. Use {@link #shutdown shutdown} instead. 1.48 + */ 1.49 + public void close() throws IOException; 1.50 + 1.51 + /** 1.52 + * Checks if this connection is open. 1.53 + * @return true if it is open, false if it is closed. 1.54 + */ 1.55 + public boolean isOpen(); 1.56 + 1.57 + /** 1.58 + * Checks whether this connection has gone down. 1.59 + * Network connections may get closed during some time of inactivity 1.60 + * for several reasons. The next time a read is attempted on such a 1.61 + * connection it will throw an IOException. 1.62 + * This method tries to alleviate this inconvenience by trying to 1.63 + * find out if a connection is still usable. Implementations may do 1.64 + * that by attempting a read with a very small timeout. Thus this 1.65 + * method may block for a small amount of time before returning a result. 1.66 + * It is therefore an <i>expensive</i> operation. 1.67 + * 1.68 + * @return <code>true</code> if attempts to use this connection are 1.69 + * likely to succeed, or <code>false</code> if they are likely 1.70 + * to fail and this connection should be closed 1.71 + */ 1.72 + public boolean isStale(); 1.73 + 1.74 + /** 1.75 + * Sets the socket timeout value. 1.76 + * 1.77 + * @param timeout timeout value in milliseconds 1.78 + */ 1.79 + void setSocketTimeout(int timeout); 1.80 + 1.81 + /** 1.82 + * Returns the socket timeout value. 1.83 + * 1.84 + * @return positive value in milliseconds if a timeout is set, 1.85 + * <code>0</code> if timeout is disabled or <code>-1</code> if 1.86 + * timeout is undefined. 1.87 + */ 1.88 + int getSocketTimeout(); 1.89 + 1.90 + /** 1.91 + * Force-closes this connection. 1.92 + * This is the only method of a connection which may be called 1.93 + * from a different thread to terminate the connection. 1.94 + * This method will not attempt to flush the transmitter's 1.95 + * internal buffer prior to closing the underlying socket. 1.96 + */ 1.97 + public void shutdown() throws IOException; 1.98 + 1.99 + /** 1.100 + * Returns a collection of connection metrics. 1.101 + * 1.102 + * @return HttpConnectionMetrics 1.103 + */ 1.104 + HttpConnectionMetrics getMetrics(); 1.105 + 1.106 +}