Javadoc and code cleanups
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@765710 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0b44b69b29
commit
b44aee815b
|
@ -39,8 +39,6 @@ import org.apache.http.conn.scheme.SocketFactory;
|
|||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface for opening {@link OperatedClientConnection connections}.
|
||||
* This interface encapsulates the logic to create sockets and to
|
||||
|
@ -52,24 +50,16 @@ import org.apache.http.protocol.HttpContext;
|
|||
* sockets. Creating a tunnelled connection through a proxy, however,
|
||||
* is not within the scope of the operator.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$ $Date$
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ClientConnectionOperator {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new connection that can be operated.
|
||||
*
|
||||
* @return a new, unopened connection for use with this operator
|
||||
*/
|
||||
OperatedClientConnection createConnection()
|
||||
;
|
||||
|
||||
OperatedClientConnection createConnection();
|
||||
|
||||
/**
|
||||
* Opens a connection to the given target host.
|
||||
|
@ -88,9 +78,7 @@ public interface ClientConnectionOperator {
|
|||
InetAddress local,
|
||||
HttpContext context,
|
||||
HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Updates a connection with a layered secure connection.
|
||||
|
@ -111,9 +99,7 @@ public interface ClientConnectionOperator {
|
|||
HttpHost target,
|
||||
HttpContext context,
|
||||
HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
throws IOException;
|
||||
|
||||
|
||||
} // interface ClientConnectionOperator
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $HeadURL: $
|
||||
* $Revision: $
|
||||
* $Date: $
|
||||
* $HeadURL:$
|
||||
* $Revision:$
|
||||
* $Date:$
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -38,10 +38,6 @@ import org.apache.http.protocol.HttpContext;
|
|||
* Interface for deciding how long a connection can remain
|
||||
* idle before being reused.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @version $Revision: $
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ConnectionKeepAliveStrategy {
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.apache.http.conn;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for releasing a connection.
|
||||
* This can be implemented by various "trigger" objects which are
|
||||
|
@ -45,11 +44,6 @@ import java.io.IOException;
|
|||
* The first invocation releases the connection, subsequent calls
|
||||
* are ignored.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ConnectionReleaseTrigger {
|
||||
|
@ -66,20 +60,17 @@ public interface ConnectionReleaseTrigger {
|
|||
* anyway.
|
||||
*/
|
||||
void releaseConnection()
|
||||
throws IOException
|
||||
;
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Releases the connection without the option of keep-alive.
|
||||
* This is a "hard" release that implies a shutdown of the connection.
|
||||
* Use {@link #releaseConnection releaseConnection} for a graceful release.
|
||||
* Use {@link #releaseConnection()} for a graceful release.
|
||||
*
|
||||
* @throws IOException in case of an IO problem.
|
||||
* The connection will be released anyway.
|
||||
*/
|
||||
void abortConnection()
|
||||
throws IOException
|
||||
;
|
||||
throws IOException;
|
||||
|
||||
|
||||
} // interface ConnectionReleaseTrigger
|
||||
}
|
||||
|
|
|
@ -40,28 +40,20 @@ import net.jcip.annotations.NotThreadSafe;
|
|||
* Primarily used to auto-release an underlying
|
||||
* {@link ManagedClientConnection connection}
|
||||
* when the response body is consumed or no longer needed.
|
||||
*
|
||||
* <p>
|
||||
* This class is based on <code>AutoCloseInputStream</code> in HttpClient 3.1,
|
||||
* but has notable differences. It does not allow mark/reset, distinguishes
|
||||
* different kinds of event, and does not always close the underlying stream
|
||||
* on EOF. That decision is left to the {@link EofSensorWatcher watcher}.
|
||||
* </p>
|
||||
*
|
||||
* @see EofSensorWatcher EofSensorWatcher
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$
|
||||
* @see EofSensorWatcher
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
// don't use FilterInputStream as the base class, we'd have to
|
||||
// override markSupported(), mark(), and reset() to disable them
|
||||
@NotThreadSafe
|
||||
public class EofSensorInputStream extends InputStream
|
||||
implements ConnectionReleaseTrigger {
|
||||
public class EofSensorInputStream extends InputStream implements ConnectionReleaseTrigger {
|
||||
|
||||
/**
|
||||
* The wrapped input stream, while accessible.
|
||||
|
@ -70,7 +62,6 @@ public class EofSensorInputStream extends InputStream
|
|||
*/
|
||||
protected InputStream wrappedStream;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether this stream itself is closed.
|
||||
* If it isn't, but {@link #wrappedStream wrappedStream}
|
||||
|
@ -86,7 +77,6 @@ public class EofSensorInputStream extends InputStream
|
|||
/** The watcher to be notified, if any. */
|
||||
private EofSensorWatcher eofWatcher;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new EOF sensor.
|
||||
* If no watcher is passed, the underlying stream will simply be
|
||||
|
@ -110,7 +100,6 @@ public class EofSensorInputStream extends InputStream
|
|||
eofWatcher = watcher;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the underlying stream can be read from.
|
||||
*
|
||||
|
@ -127,8 +116,6 @@ public class EofSensorInputStream extends InputStream
|
|||
return (wrappedStream != null);
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see base class InputStream
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int l = -1;
|
||||
|
@ -146,8 +133,6 @@ public class EofSensorInputStream extends InputStream
|
|||
return l;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see base class InputStream
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int l = -1;
|
||||
|
@ -165,8 +150,6 @@ public class EofSensorInputStream extends InputStream
|
|||
return l;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see base class InputStream
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
int l = -1;
|
||||
|
@ -183,8 +166,6 @@ public class EofSensorInputStream extends InputStream
|
|||
return l;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see base class InputStream
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
int a = 0; // not -1
|
||||
|
@ -202,8 +183,6 @@ public class EofSensorInputStream extends InputStream
|
|||
return a;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see base class InputStream
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// tolerate multiple calls to close()
|
||||
|
@ -211,7 +190,6 @@ public class EofSensorInputStream extends InputStream
|
|||
checkClose();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detects EOF and notifies the watcher.
|
||||
* This method should only be called while the underlying stream is
|
||||
|
@ -243,7 +221,6 @@ public class EofSensorInputStream extends InputStream
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detects stream close and notifies the watcher.
|
||||
* There's not much to detect since this is called by {@link #close close}.
|
||||
|
@ -270,7 +247,6 @@ public class EofSensorInputStream extends InputStream
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detects stream abort and notifies the watcher.
|
||||
* There's not much to detect since this is called by
|
||||
|
@ -299,12 +275,11 @@ public class EofSensorInputStream extends InputStream
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Same as {@link #close close()}.
|
||||
*/
|
||||
public void releaseConnection() throws IOException {
|
||||
this.close();
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -320,5 +295,5 @@ public class EofSensorInputStream extends InputStream
|
|||
checkAbort();
|
||||
}
|
||||
|
||||
} // class EOFSensorInputStream
|
||||
}
|
||||
|
||||
|
|
|
@ -33,16 +33,10 @@ package org.apache.http.conn;
|
|||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* A watcher for {@link EofSensorInputStream EofSensorInputStream}.
|
||||
* Each stream will notify its watcher at most once.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface EofSensorWatcher {
|
||||
|
@ -61,9 +55,7 @@ public interface EofSensorWatcher {
|
|||
* wrapped stream alone, as if <code>false</code> was returned.
|
||||
*/
|
||||
boolean eofDetected(InputStream wrapped)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Indicates that the {@link EofSensorInputStream stream} is closed.
|
||||
|
@ -81,9 +73,7 @@ public interface EofSensorWatcher {
|
|||
* wrapped stream alone, as if <code>false</code> was returned.
|
||||
*/
|
||||
boolean streamClosed(InputStream wrapped)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Indicates that the {@link EofSensorInputStream stream} is aborted.
|
||||
|
@ -104,8 +94,6 @@ public interface EofSensorWatcher {
|
|||
* wrapped stream alone, as if <code>false</code> was returned.
|
||||
*/
|
||||
boolean streamAbort(InputStream wrapped)
|
||||
throws IOException
|
||||
;
|
||||
throws IOException;
|
||||
|
||||
|
||||
} // interface EofSensorWatcher
|
||||
}
|
||||
|
|
|
@ -44,17 +44,10 @@ import org.apache.http.protocol.HttpContext;
|
|||
|
||||
import org.apache.http.conn.routing.HttpRoute;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A client-side connection with advanced connection logic.
|
||||
* Instances are typically obtained from a connection manager.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ManagedClientConnection extends
|
||||
|
@ -69,9 +62,7 @@ public interface ManagedClientConnection extends
|
|||
* @return <code>true</code> if this connection is secure,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean isSecure()
|
||||
;
|
||||
|
||||
boolean isSecure();
|
||||
|
||||
/**
|
||||
* Obtains the current route of this connection.
|
||||
|
@ -79,9 +70,7 @@ public interface ManagedClientConnection extends
|
|||
* @return the route established so far, or
|
||||
* <code>null</code> if not connected
|
||||
*/
|
||||
HttpRoute getRoute()
|
||||
;
|
||||
|
||||
HttpRoute getRoute();
|
||||
|
||||
/**
|
||||
* Obtains the SSL session of the underlying connection, if any.
|
||||
|
@ -99,9 +88,7 @@ public interface ManagedClientConnection extends
|
|||
* @return the underlying SSL session if available,
|
||||
* <code>null</code> otherwise
|
||||
*/
|
||||
SSLSession getSSLSession()
|
||||
;
|
||||
|
||||
SSLSession getSSLSession();
|
||||
|
||||
/**
|
||||
* Opens this connection according to the given route.
|
||||
|
@ -114,9 +101,7 @@ public interface ManagedClientConnection extends
|
|||
* @throws IOException in case of a problem
|
||||
*/
|
||||
void open(HttpRoute route, HttpContext context, HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Indicates that a tunnel to the target has been established.
|
||||
|
@ -136,9 +121,7 @@ public interface ManagedClientConnection extends
|
|||
* @throws IOException in case of a problem
|
||||
*/
|
||||
void tunnelTarget(boolean secure, HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Indicates that a tunnel to an intermediate proxy has been established.
|
||||
|
@ -161,9 +144,7 @@ public interface ManagedClientConnection extends
|
|||
* @throws IOException in case of a problem
|
||||
*/
|
||||
void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Layers a new protocol on top of a {@link #tunnelTarget tunnelled}
|
||||
|
@ -179,9 +160,7 @@ public interface ManagedClientConnection extends
|
|||
* @throws IOException in case of a problem
|
||||
*/
|
||||
void layerProtocol(HttpContext context, HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Marks this connection as being in a reusable communication state.
|
||||
|
@ -197,9 +176,7 @@ public interface ManagedClientConnection extends
|
|||
* A {@link #getRoute route} mismatch, the connection being closed,
|
||||
* or other circumstances might prevent reuse.
|
||||
*/
|
||||
void markReusable()
|
||||
;
|
||||
|
||||
void markReusable();
|
||||
|
||||
/**
|
||||
* Marks this connection as not being in a reusable state.
|
||||
|
@ -214,9 +191,7 @@ public interface ManagedClientConnection extends
|
|||
* automatically unmark the state as non-reusable. It can then
|
||||
* be switched back using {@link #markReusable markReusable}.
|
||||
*/
|
||||
void unmarkReusable()
|
||||
;
|
||||
|
||||
void unmarkReusable();
|
||||
|
||||
/**
|
||||
* Indicates whether this connection is in a reusable communication state.
|
||||
|
@ -227,8 +202,7 @@ public interface ManagedClientConnection extends
|
|||
* a reusable communication state,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean isMarkedReusable()
|
||||
;
|
||||
boolean isMarkedReusable();
|
||||
|
||||
/**
|
||||
* Assigns a state object to this connection. Connection managers may make
|
||||
|
@ -236,16 +210,14 @@ public interface ManagedClientConnection extends
|
|||
*
|
||||
* @param state The state object
|
||||
*/
|
||||
void setState(Object state)
|
||||
;
|
||||
void setState(Object state);
|
||||
|
||||
/**
|
||||
* Returns the state object associated with this connection.
|
||||
*
|
||||
* @return The state object
|
||||
*/
|
||||
Object getState()
|
||||
;
|
||||
Object getState();
|
||||
|
||||
/**
|
||||
* Sets the duration that this connection can remain idle before it is
|
||||
|
@ -257,4 +229,4 @@ public interface ManagedClientConnection extends
|
|||
*/
|
||||
void setIdleDuration(long duration, TimeUnit unit);
|
||||
|
||||
} // interface ManagedClientConnection
|
||||
}
|
||||
|
|
|
@ -39,22 +39,14 @@ import org.apache.http.HttpHost;
|
|||
import org.apache.http.HttpInetConnection;
|
||||
import org.apache.http.params.HttpParams;
|
||||
|
||||
|
||||
/**
|
||||
* A client-side connection that relies on outside logic to connect sockets to the
|
||||
* appropriate hosts. It can be operated directly by an application, or through an
|
||||
* {@link ClientConnectionOperator operator}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$ $Date$
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface OperatedClientConnection
|
||||
extends HttpClientConnection, HttpInetConnection {
|
||||
public interface OperatedClientConnection extends HttpClientConnection, HttpInetConnection {
|
||||
|
||||
/**
|
||||
* Obtains the target host for this connection.
|
||||
|
@ -68,8 +60,7 @@ public interface OperatedClientConnection
|
|||
*
|
||||
* @return the host to which this connection is opened
|
||||
*/
|
||||
HttpHost getTargetHost()
|
||||
;
|
||||
HttpHost getTargetHost();
|
||||
|
||||
/**
|
||||
* Indicates whether this connection is secure.
|
||||
|
@ -80,8 +71,7 @@ public interface OperatedClientConnection
|
|||
* @return <code>true</code> if this connection is secure,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean isSecure()
|
||||
;
|
||||
boolean isSecure();
|
||||
|
||||
/**
|
||||
* Obtains the socket for this connection.
|
||||
|
@ -92,13 +82,7 @@ public interface OperatedClientConnection
|
|||
* @return the socket for communicating with the
|
||||
* {@link #getTargetHost target host}
|
||||
*/
|
||||
Socket getSocket()
|
||||
;
|
||||
|
||||
|
||||
// There is no getParams(). For the moment, we
|
||||
// do not require connections to store parameters.
|
||||
|
||||
Socket getSocket();
|
||||
|
||||
/**
|
||||
* Signals that this connection is in the process of being open.
|
||||
|
@ -122,9 +106,7 @@ public interface OperatedClientConnection
|
|||
* @param target the target host of this connection
|
||||
*/
|
||||
void opening(Socket sock, HttpHost target)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Signals that the connection has been successfully open.
|
||||
|
@ -139,9 +121,7 @@ public interface OperatedClientConnection
|
|||
* to determine buffer sizes.
|
||||
*/
|
||||
void openCompleted(boolean secure, HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Updates this connection.
|
||||
|
@ -166,8 +146,6 @@ public interface OperatedClientConnection
|
|||
*/
|
||||
void update(Socket sock, HttpHost target,
|
||||
boolean secure, HttpParams params)
|
||||
throws IOException
|
||||
;
|
||||
throws IOException;
|
||||
|
||||
|
||||
} // interface OperatedClientConnection
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
package org.apache.http.impl.conn;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
|
@ -51,14 +50,16 @@ import org.apache.http.io.SessionOutputBuffer;
|
|||
|
||||
import org.apache.http.conn.OperatedClientConnection;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of an operated client connection.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$ $Date$
|
||||
* <p>
|
||||
* The following parameters can be used to customize the behavior of this
|
||||
* class:
|
||||
* <ul>
|
||||
* <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -85,25 +86,19 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
super();
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface OperatedClientConnection
|
||||
public final HttpHost getTargetHost() {
|
||||
return this.targetHost;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface OperatedClientConnection
|
||||
public final boolean isSecure() {
|
||||
return this.connSecure;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Socket getSocket() {
|
||||
return this.socket;
|
||||
}
|
||||
|
||||
|
||||
public void opening(Socket sock, HttpHost target) throws IOException {
|
||||
assertNotOpen();
|
||||
this.socket = sock;
|
||||
|
@ -117,7 +112,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void openCompleted(boolean secure, HttpParams params) throws IOException {
|
||||
assertNotOpen();
|
||||
if (params == null) {
|
||||
|
@ -151,8 +145,7 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
if (sock != null)
|
||||
sock.close();
|
||||
|
||||
} // shutdown
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
|
@ -160,7 +153,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
super.close();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected SessionInputBuffer createSessionInputBuffer(
|
||||
final Socket socket,
|
||||
|
@ -179,7 +171,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
return inbuffer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected SessionOutputBuffer createSessionOutputBuffer(
|
||||
final Socket socket,
|
||||
|
@ -198,7 +189,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
return outbuffer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected HttpMessageParser createResponseParser(
|
||||
final SessionInputBuffer buffer,
|
||||
|
@ -209,8 +199,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
(buffer, null, responseFactory, params);
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface OperatedClientConnection
|
||||
public void update(Socket sock, HttpHost target,
|
||||
boolean secure, HttpParams params)
|
||||
throws IOException {
|
||||
|
@ -231,9 +219,7 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
}
|
||||
targetHost = target;
|
||||
connSecure = secure;
|
||||
|
||||
} // update
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse receiveResponseHeader() throws HttpException, IOException {
|
||||
|
@ -248,7 +234,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendRequestHeader(HttpRequest request) throws HttpException, IOException {
|
||||
super.sendRequestHeader(request);
|
||||
|
@ -261,4 +246,4 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
}
|
||||
}
|
||||
|
||||
} // class DefaultClientConnection
|
||||
}
|
||||
|
|
|
@ -51,29 +51,29 @@ import org.apache.http.conn.scheme.Scheme;
|
|||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.scheme.SocketFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of a
|
||||
* {@link ClientConnectionOperator ClientConnectionOperator}.
|
||||
* It uses a {@link SchemeRegistry SchemeRegistry} to look up
|
||||
* {@link SocketFactory SocketFactory} objects.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @version $Revision$ $Date$
|
||||
* Default implementation of a {@link ClientConnectionOperator}. It uses
|
||||
* a {@link SchemeRegistry} to look up {@link SocketFactory} objects.
|
||||
* <p>
|
||||
* The following parameters can be used to customize the behavior of this
|
||||
* class:
|
||||
* <ul>
|
||||
* <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_LINGER}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class DefaultClientConnectionOperator
|
||||
implements ClientConnectionOperator {
|
||||
|
||||
public class DefaultClientConnectionOperator implements ClientConnectionOperator {
|
||||
|
||||
/** The scheme registry for looking up socket factories. */
|
||||
protected final SchemeRegistry schemeRegistry; // @ThreadSafe
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new client connection operator for the given scheme registry.
|
||||
*
|
||||
|
@ -87,14 +87,10 @@ public class DefaultClientConnectionOperator
|
|||
schemeRegistry = schemes;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface ClientConnectionOperator
|
||||
public OperatedClientConnection createConnection() {
|
||||
return new DefaultClientConnection();
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface ClientConnectionOperator
|
||||
public void openConnection(OperatedClientConnection conn,
|
||||
HttpHost target,
|
||||
InetAddress local,
|
||||
|
@ -136,10 +132,8 @@ public class DefaultClientConnectionOperator
|
|||
}
|
||||
prepareSocket(sock, context, params);
|
||||
conn.openCompleted(sf.isSecure(sock), params);
|
||||
} // openConnection
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface ClientConnectionOperator
|
||||
public void updateSecureConnection(OperatedClientConnection conn,
|
||||
HttpHost target,
|
||||
HttpContext context,
|
||||
|
@ -155,7 +149,6 @@ public class DefaultClientConnectionOperator
|
|||
throw new IllegalArgumentException
|
||||
("Target host must not be null.");
|
||||
}
|
||||
//@@@ is context allowed to be null?
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException
|
||||
("Parameters must not be null.");
|
||||
|
@ -182,10 +175,7 @@ public class DefaultClientConnectionOperator
|
|||
}
|
||||
prepareSocket(sock, context, params);
|
||||
conn.update(sock, target, lsf.isSecure(sock), params);
|
||||
//@@@ error handling: close the layered socket in case of exception?
|
||||
|
||||
} // updateSecureConnection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs standard initializations on a newly created socket.
|
||||
|
@ -200,9 +190,6 @@ public class DefaultClientConnectionOperator
|
|||
HttpParams params)
|
||||
throws IOException {
|
||||
|
||||
// context currently not used, but derived classes may need it
|
||||
//@@@ is context allowed to be null?
|
||||
|
||||
sock.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
|
||||
sock.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
|
||||
|
||||
|
@ -210,9 +197,7 @@ public class DefaultClientConnectionOperator
|
|||
if (linger >= 0) {
|
||||
sock.setSoLinger(linger > 0, linger);
|
||||
}
|
||||
}
|
||||
|
||||
} // prepareSocket
|
||||
|
||||
|
||||
} // class DefaultClientConnectionOperator
|
||||
}
|
||||
|
||||
|
|
|
@ -48,13 +48,19 @@ import org.apache.http.conn.scheme.SchemeRegistry;
|
|||
|
||||
import org.apache.http.conn.params.ConnRouteParams;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of an {@link HttpRoutePlanner}.
|
||||
* This implementation is based on
|
||||
* {@link org.apache.http.conn.params.ConnRoutePNames parameters}.
|
||||
* It will not make use of any Java system properties,
|
||||
* nor of system or browser proxy settings.
|
||||
* Default implementation of an {@link HttpRoutePlanner}. This implementation
|
||||
* is based on {@link org.apache.http.conn.params.ConnRoutePNames parameters}.
|
||||
* It will not make use of any Java system properties, nor of system or
|
||||
* browser proxy settings.
|
||||
* <p>
|
||||
* The following parameters can be used to customize the behavior of this
|
||||
* class:
|
||||
* <ul>
|
||||
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY}</li>
|
||||
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}</li>
|
||||
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#FORCED_ROUTE}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -64,7 +70,6 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
|
|||
/** The scheme registry. */
|
||||
protected final SchemeRegistry schemeRegistry; // class is @ThreadSafe
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new default route planner.
|
||||
*
|
||||
|
@ -78,8 +83,6 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
|
|||
schemeRegistry = schreg;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface HttpRoutePlanner
|
||||
public HttpRoute determineRoute(HttpHost target,
|
||||
HttpRequest request,
|
||||
HttpContext context)
|
||||
|
@ -122,5 +125,4 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
|
|||
return route;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,15 @@ import org.apache.http.params.HttpParams;
|
|||
import org.apache.http.util.CharArrayBuffer;
|
||||
|
||||
/**
|
||||
* Default HTTP response parser implementation.
|
||||
* <p>
|
||||
* The following parameters can be used to customize the behavior of this
|
||||
* class:
|
||||
* <ul>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
|
||||
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
|
||||
* <li>{@link org.apache.http.conn.params.ConnConnectionPNames#MAX_STATUS_LINE_GARBAGE}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
|
|
@ -63,6 +63,13 @@ import org.apache.http.conn.params.ConnRouteParams;
|
|||
* {@link org.apache.http.conn.params.ConnRoutePNames parameters},
|
||||
* though not the {@link
|
||||
* org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}.
|
||||
* <p>
|
||||
* The following parameters can be used to customize the behavior of this
|
||||
* class:
|
||||
* <ul>
|
||||
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}</li>
|
||||
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#FORCED_ROUTE}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -75,7 +82,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
/** The proxy selector to use, or <code>null</code> for system default. */
|
||||
protected ProxySelector proxySelector;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new proxy selector route planner.
|
||||
*
|
||||
|
@ -94,7 +100,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
proxySelector = prosel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the proxy selector to use.
|
||||
*
|
||||
|
@ -104,7 +109,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
return this.proxySelector;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the proxy selector to use.
|
||||
*
|
||||
|
@ -115,9 +119,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
this.proxySelector = prosel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// non-javadoc, see interface HttpRoutePlanner
|
||||
public HttpRoute determineRoute(HttpHost target,
|
||||
HttpRequest request,
|
||||
HttpContext context)
|
||||
|
@ -160,7 +161,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
return route;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines a proxy for the given target.
|
||||
*
|
||||
|
@ -211,7 +211,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a host from an {@link InetSocketAddress}.
|
||||
*
|
||||
|
@ -232,8 +231,7 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chooses a proxy from a list of available proxies.
|
||||
* The default implementation just picks the first non-SOCKS proxy
|
||||
* from the list. If there are only SOCKS proxies,
|
||||
|
@ -247,8 +245,7 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
* @param request the request to be sent, never <code>null</code>
|
||||
* @param context the context, or <code>null</code>
|
||||
*
|
||||
* @return a proxy of type {@link Proxy.Type#DIRECT DIRECT}
|
||||
* or {@link Proxy.Type#HTTP HTTP}, never <code>null</code>
|
||||
* @return a proxy type
|
||||
*/
|
||||
protected Proxy chooseProxy(List<Proxy> proxies,
|
||||
HttpHost target,
|
||||
|
@ -290,5 +287,5 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
|
|||
return result;
|
||||
}
|
||||
|
||||
} // class ProxySelectorRoutePlanner
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue