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:
Oleg Kalnichevski 2009-04-16 18:12:30 +00:00
parent 0b44b69b29
commit b44aee815b
12 changed files with 101 additions and 237 deletions

View File

@ -39,8 +39,6 @@ import org.apache.http.conn.scheme.SocketFactory;
import org.apache.http.params.HttpParams; import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
/** /**
* Interface for opening {@link OperatedClientConnection connections}. * Interface for opening {@link OperatedClientConnection connections}.
* This interface encapsulates the logic to create sockets and to * 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, * sockets. Creating a tunnelled connection through a proxy, however,
* is not within the scope of the operator. * is not within the scope of the operator.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$ $Date$
*
* @since 4.0 * @since 4.0
*/ */
public interface ClientConnectionOperator { public interface ClientConnectionOperator {
/** /**
* Creates a new connection that can be operated. * Creates a new connection that can be operated.
* *
* @return a new, unopened connection for use with this operator * @return a new, unopened connection for use with this operator
*/ */
OperatedClientConnection createConnection() OperatedClientConnection createConnection();
;
/** /**
* Opens a connection to the given target host. * Opens a connection to the given target host.
@ -88,9 +78,7 @@ public interface ClientConnectionOperator {
InetAddress local, InetAddress local,
HttpContext context, HttpContext context,
HttpParams params) HttpParams params)
throws IOException throws IOException;
;
/** /**
* Updates a connection with a layered secure connection. * Updates a connection with a layered secure connection.
@ -111,9 +99,7 @@ public interface ClientConnectionOperator {
HttpHost target, HttpHost target,
HttpContext context, HttpContext context,
HttpParams params) HttpParams params)
throws IOException throws IOException;
;
}
} // interface ClientConnectionOperator

View File

@ -1,7 +1,7 @@
/* /*
* $HeadURL: $ * $HeadURL:$
* $Revision: $ * $Revision:$
* $Date: $ * $Date:$
* *
* ==================================================================== * ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
@ -37,10 +37,6 @@ import org.apache.http.protocol.HttpContext;
/** /**
* Interface for deciding how long a connection can remain * Interface for deciding how long a connection can remain
* idle before being reused. * idle before being reused.
*
*
*
* @version $Revision: $
* *
* @since 4.0 * @since 4.0
*/ */

View File

@ -32,7 +32,6 @@ package org.apache.http.conn;
import java.io.IOException; import java.io.IOException;
/** /**
* Interface for releasing a connection. * Interface for releasing a connection.
* This can be implemented by various "trigger" objects which are * 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 * The first invocation releases the connection, subsequent calls
* are ignored. * are ignored.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
*
* @since 4.0 * @since 4.0
*/ */
public interface ConnectionReleaseTrigger { public interface ConnectionReleaseTrigger {
@ -66,20 +60,17 @@ public interface ConnectionReleaseTrigger {
* anyway. * anyway.
*/ */
void releaseConnection() void releaseConnection()
throws IOException throws IOException;
;
/** /**
* Releases the connection without the option of keep-alive. * Releases the connection without the option of keep-alive.
* This is a "hard" release that implies a shutdown of the connection. * 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. * @throws IOException in case of an IO problem.
* The connection will be released anyway. * The connection will be released anyway.
*/ */
void abortConnection() void abortConnection()
throws IOException throws IOException;
;
}
} // interface ConnectionReleaseTrigger

View File

@ -40,28 +40,20 @@ import net.jcip.annotations.NotThreadSafe;
* Primarily used to auto-release an underlying * Primarily used to auto-release an underlying
* {@link ManagedClientConnection connection} * {@link ManagedClientConnection connection}
* when the response body is consumed or no longer needed. * when the response body is consumed or no longer needed.
*
* <p> * <p>
* This class is based on <code>AutoCloseInputStream</code> in HttpClient 3.1, * This class is based on <code>AutoCloseInputStream</code> in HttpClient 3.1,
* but has notable differences. It does not allow mark/reset, distinguishes * but has notable differences. It does not allow mark/reset, distinguishes
* different kinds of event, and does not always close the underlying stream * different kinds of event, and does not always close the underlying stream
* on EOF. That decision is left to the {@link EofSensorWatcher watcher}. * on EOF. That decision is left to the {@link EofSensorWatcher watcher}.
* </p>
* *
* @see EofSensorWatcher EofSensorWatcher * @see EofSensorWatcher
*
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
* *
* @since 4.0 * @since 4.0
*/ */
// don't use FilterInputStream as the base class, we'd have to // don't use FilterInputStream as the base class, we'd have to
// override markSupported(), mark(), and reset() to disable them // override markSupported(), mark(), and reset() to disable them
@NotThreadSafe @NotThreadSafe
public class EofSensorInputStream extends InputStream public class EofSensorInputStream extends InputStream implements ConnectionReleaseTrigger {
implements ConnectionReleaseTrigger {
/** /**
* The wrapped input stream, while accessible. * The wrapped input stream, while accessible.
@ -70,7 +62,6 @@ public class EofSensorInputStream extends InputStream
*/ */
protected InputStream wrappedStream; protected InputStream wrappedStream;
/** /**
* Indicates whether this stream itself is closed. * Indicates whether this stream itself is closed.
* If it isn't, but {@link #wrappedStream wrappedStream} * If it isn't, but {@link #wrappedStream wrappedStream}
@ -86,7 +77,6 @@ public class EofSensorInputStream extends InputStream
/** The watcher to be notified, if any. */ /** The watcher to be notified, if any. */
private EofSensorWatcher eofWatcher; private EofSensorWatcher eofWatcher;
/** /**
* Creates a new EOF sensor. * Creates a new EOF sensor.
* If no watcher is passed, the underlying stream will simply be * If no watcher is passed, the underlying stream will simply be
@ -110,7 +100,6 @@ public class EofSensorInputStream extends InputStream
eofWatcher = watcher; eofWatcher = watcher;
} }
/** /**
* Checks whether the underlying stream can be read from. * Checks whether the underlying stream can be read from.
* *
@ -127,8 +116,6 @@ public class EofSensorInputStream extends InputStream
return (wrappedStream != null); return (wrappedStream != null);
} }
// non-javadoc, see base class InputStream
@Override @Override
public int read() throws IOException { public int read() throws IOException {
int l = -1; int l = -1;
@ -146,8 +133,6 @@ public class EofSensorInputStream extends InputStream
return l; return l;
} }
// non-javadoc, see base class InputStream
@Override @Override
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
int l = -1; int l = -1;
@ -165,8 +150,6 @@ public class EofSensorInputStream extends InputStream
return l; return l;
} }
// non-javadoc, see base class InputStream
@Override @Override
public int read(byte[] b) throws IOException { public int read(byte[] b) throws IOException {
int l = -1; int l = -1;
@ -183,8 +166,6 @@ public class EofSensorInputStream extends InputStream
return l; return l;
} }
// non-javadoc, see base class InputStream
@Override @Override
public int available() throws IOException { public int available() throws IOException {
int a = 0; // not -1 int a = 0; // not -1
@ -202,8 +183,6 @@ public class EofSensorInputStream extends InputStream
return a; return a;
} }
// non-javadoc, see base class InputStream
@Override @Override
public void close() throws IOException { public void close() throws IOException {
// tolerate multiple calls to close() // tolerate multiple calls to close()
@ -211,7 +190,6 @@ public class EofSensorInputStream extends InputStream
checkClose(); checkClose();
} }
/** /**
* Detects EOF and notifies the watcher. * Detects EOF and notifies the watcher.
* This method should only be called while the underlying stream is * 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. * Detects stream close and notifies the watcher.
* There's not much to detect since this is called by {@link #close close}. * 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. * Detects stream abort and notifies the watcher.
* There's not much to detect since this is called by * 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()}. * Same as {@link #close close()}.
*/ */
public void releaseConnection() throws IOException { public void releaseConnection() throws IOException {
this.close(); close();
} }
/** /**
@ -320,5 +295,5 @@ public class EofSensorInputStream extends InputStream
checkAbort(); checkAbort();
} }
} // class EOFSensorInputStream }

View File

@ -33,16 +33,10 @@ package org.apache.http.conn;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
/** /**
* A watcher for {@link EofSensorInputStream EofSensorInputStream}. * A watcher for {@link EofSensorInputStream EofSensorInputStream}.
* Each stream will notify its watcher at most once. * Each stream will notify its watcher at most once.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
*
* @since 4.0 * @since 4.0
*/ */
public interface EofSensorWatcher { public interface EofSensorWatcher {
@ -61,9 +55,7 @@ public interface EofSensorWatcher {
* wrapped stream alone, as if <code>false</code> was returned. * wrapped stream alone, as if <code>false</code> was returned.
*/ */
boolean eofDetected(InputStream wrapped) boolean eofDetected(InputStream wrapped)
throws IOException throws IOException;
;
/** /**
* Indicates that the {@link EofSensorInputStream stream} is closed. * 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. * wrapped stream alone, as if <code>false</code> was returned.
*/ */
boolean streamClosed(InputStream wrapped) boolean streamClosed(InputStream wrapped)
throws IOException throws IOException;
;
/** /**
* Indicates that the {@link EofSensorInputStream stream} is aborted. * 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. * wrapped stream alone, as if <code>false</code> was returned.
*/ */
boolean streamAbort(InputStream wrapped) boolean streamAbort(InputStream wrapped)
throws IOException throws IOException;
;
}
} // interface EofSensorWatcher

View File

@ -44,17 +44,10 @@ import org.apache.http.protocol.HttpContext;
import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoute;
/** /**
* A client-side connection with advanced connection logic. * A client-side connection with advanced connection logic.
* Instances are typically obtained from a connection manager. * Instances are typically obtained from a connection manager.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
*
* @since 4.0 * @since 4.0
*/ */
public interface ManagedClientConnection extends public interface ManagedClientConnection extends
@ -69,9 +62,7 @@ public interface ManagedClientConnection extends
* @return <code>true</code> if this connection is secure, * @return <code>true</code> if this connection is secure,
* <code>false</code> otherwise * <code>false</code> otherwise
*/ */
boolean isSecure() boolean isSecure();
;
/** /**
* Obtains the current route of this connection. * Obtains the current route of this connection.
@ -79,9 +70,7 @@ public interface ManagedClientConnection extends
* @return the route established so far, or * @return the route established so far, or
* <code>null</code> if not connected * <code>null</code> if not connected
*/ */
HttpRoute getRoute() HttpRoute getRoute();
;
/** /**
* Obtains the SSL session of the underlying connection, if any. * 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, * @return the underlying SSL session if available,
* <code>null</code> otherwise * <code>null</code> otherwise
*/ */
SSLSession getSSLSession() SSLSession getSSLSession();
;
/** /**
* Opens this connection according to the given route. * Opens this connection according to the given route.
@ -114,9 +101,7 @@ public interface ManagedClientConnection extends
* @throws IOException in case of a problem * @throws IOException in case of a problem
*/ */
void open(HttpRoute route, HttpContext context, HttpParams params) void open(HttpRoute route, HttpContext context, HttpParams params)
throws IOException throws IOException;
;
/** /**
* Indicates that a tunnel to the target has been established. * 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 * @throws IOException in case of a problem
*/ */
void tunnelTarget(boolean secure, HttpParams params) void tunnelTarget(boolean secure, HttpParams params)
throws IOException throws IOException;
;
/** /**
* Indicates that a tunnel to an intermediate proxy has been established. * 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 * @throws IOException in case of a problem
*/ */
void tunnelProxy(HttpHost next, boolean secure, HttpParams params) void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
throws IOException throws IOException;
;
/** /**
* Layers a new protocol on top of a {@link #tunnelTarget tunnelled} * 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 * @throws IOException in case of a problem
*/ */
void layerProtocol(HttpContext context, HttpParams params) void layerProtocol(HttpContext context, HttpParams params)
throws IOException throws IOException;
;
/** /**
* Marks this connection as being in a reusable communication state. * 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, * A {@link #getRoute route} mismatch, the connection being closed,
* or other circumstances might prevent reuse. * or other circumstances might prevent reuse.
*/ */
void markReusable() void markReusable();
;
/** /**
* Marks this connection as not being in a reusable state. * 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 * automatically unmark the state as non-reusable. It can then
* be switched back using {@link #markReusable markReusable}. * be switched back using {@link #markReusable markReusable}.
*/ */
void unmarkReusable() void unmarkReusable();
;
/** /**
* Indicates whether this connection is in a reusable communication state. * Indicates whether this connection is in a reusable communication state.
@ -227,8 +202,7 @@ public interface ManagedClientConnection extends
* a reusable communication state, * a reusable communication state,
* <code>false</code> otherwise * <code>false</code> otherwise
*/ */
boolean isMarkedReusable() boolean isMarkedReusable();
;
/** /**
* Assigns a state object to this connection. Connection managers may make * Assigns a state object to this connection. Connection managers may make
@ -236,16 +210,14 @@ public interface ManagedClientConnection extends
* *
* @param state The state object * @param state The state object
*/ */
void setState(Object state) void setState(Object state);
;
/** /**
* Returns the state object associated with this connection. * Returns the state object associated with this connection.
* *
* @return The state object * @return The state object
*/ */
Object getState() Object getState();
;
/** /**
* Sets the duration that this connection can remain idle before it is * 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); void setIdleDuration(long duration, TimeUnit unit);
} // interface ManagedClientConnection }

View File

@ -39,22 +39,14 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpInetConnection; import org.apache.http.HttpInetConnection;
import org.apache.http.params.HttpParams; import org.apache.http.params.HttpParams;
/** /**
* A client-side connection that relies on outside logic to connect sockets to the * 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 * appropriate hosts. It can be operated directly by an application, or through an
* {@link ClientConnectionOperator operator}. * {@link ClientConnectionOperator operator}.
* *
*
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$ $Date$
*
* @since 4.0 * @since 4.0
*/ */
public interface OperatedClientConnection public interface OperatedClientConnection extends HttpClientConnection, HttpInetConnection {
extends HttpClientConnection, HttpInetConnection {
/** /**
* Obtains the target host for this connection. * Obtains the target host for this connection.
@ -68,8 +60,7 @@ public interface OperatedClientConnection
* *
* @return the host to which this connection is opened * @return the host to which this connection is opened
*/ */
HttpHost getTargetHost() HttpHost getTargetHost();
;
/** /**
* Indicates whether this connection is secure. * Indicates whether this connection is secure.
@ -80,8 +71,7 @@ public interface OperatedClientConnection
* @return <code>true</code> if this connection is secure, * @return <code>true</code> if this connection is secure,
* <code>false</code> otherwise * <code>false</code> otherwise
*/ */
boolean isSecure() boolean isSecure();
;
/** /**
* Obtains the socket for this connection. * Obtains the socket for this connection.
@ -92,13 +82,7 @@ public interface OperatedClientConnection
* @return the socket for communicating with the * @return the socket for communicating with the
* {@link #getTargetHost target host} * {@link #getTargetHost target host}
*/ */
Socket getSocket() Socket getSocket();
;
// There is no getParams(). For the moment, we
// do not require connections to store parameters.
/** /**
* Signals that this connection is in the process of being open. * 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 * @param target the target host of this connection
*/ */
void opening(Socket sock, HttpHost target) void opening(Socket sock, HttpHost target)
throws IOException throws IOException;
;
/** /**
* Signals that the connection has been successfully open. * Signals that the connection has been successfully open.
@ -139,9 +121,7 @@ public interface OperatedClientConnection
* to determine buffer sizes. * to determine buffer sizes.
*/ */
void openCompleted(boolean secure, HttpParams params) void openCompleted(boolean secure, HttpParams params)
throws IOException throws IOException;
;
/** /**
* Updates this connection. * Updates this connection.
@ -166,8 +146,6 @@ public interface OperatedClientConnection
*/ */
void update(Socket sock, HttpHost target, void update(Socket sock, HttpHost target,
boolean secure, HttpParams params) boolean secure, HttpParams params)
throws IOException throws IOException;
;
}
} // interface OperatedClientConnection

View File

@ -31,7 +31,6 @@
package org.apache.http.impl.conn; package org.apache.http.impl.conn;
import java.io.IOException; import java.io.IOException;
import java.net.Socket; import java.net.Socket;
@ -51,14 +50,16 @@ import org.apache.http.io.SessionOutputBuffer;
import org.apache.http.conn.OperatedClientConnection; import org.apache.http.conn.OperatedClientConnection;
/** /**
* Default implementation of an operated client connection. * Default implementation of an operated client connection.
* * <p>
* * The following parameters can be used to customize the behavior of this
* * class:
* <!-- empty lines to avoid svn diff problems --> * <ul>
* @version $Revision$ $Date$ * <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 * @since 4.0
*/ */
@ -85,25 +86,19 @@ public class DefaultClientConnection extends SocketHttpClientConnection
super(); super();
} }
// non-javadoc, see interface OperatedClientConnection
public final HttpHost getTargetHost() { public final HttpHost getTargetHost() {
return this.targetHost; return this.targetHost;
} }
// non-javadoc, see interface OperatedClientConnection
public final boolean isSecure() { public final boolean isSecure() {
return this.connSecure; return this.connSecure;
} }
@Override @Override
public final Socket getSocket() { public final Socket getSocket() {
return this.socket; return this.socket;
} }
public void opening(Socket sock, HttpHost target) throws IOException { public void opening(Socket sock, HttpHost target) throws IOException {
assertNotOpen(); assertNotOpen();
this.socket = sock; this.socket = sock;
@ -117,7 +112,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
} }
} }
public void openCompleted(boolean secure, HttpParams params) throws IOException { public void openCompleted(boolean secure, HttpParams params) throws IOException {
assertNotOpen(); assertNotOpen();
if (params == null) { if (params == null) {
@ -151,8 +145,7 @@ public class DefaultClientConnection extends SocketHttpClientConnection
if (sock != null) if (sock != null)
sock.close(); sock.close();
} // shutdown }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
@ -160,7 +153,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
super.close(); super.close();
} }
@Override @Override
protected SessionInputBuffer createSessionInputBuffer( protected SessionInputBuffer createSessionInputBuffer(
final Socket socket, final Socket socket,
@ -179,7 +171,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
return inbuffer; return inbuffer;
} }
@Override @Override
protected SessionOutputBuffer createSessionOutputBuffer( protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket, final Socket socket,
@ -198,7 +189,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
return outbuffer; return outbuffer;
} }
@Override @Override
protected HttpMessageParser createResponseParser( protected HttpMessageParser createResponseParser(
final SessionInputBuffer buffer, final SessionInputBuffer buffer,
@ -209,8 +199,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
(buffer, null, responseFactory, params); (buffer, null, responseFactory, params);
} }
// non-javadoc, see interface OperatedClientConnection
public void update(Socket sock, HttpHost target, public void update(Socket sock, HttpHost target,
boolean secure, HttpParams params) boolean secure, HttpParams params)
throws IOException { throws IOException {
@ -231,9 +219,7 @@ public class DefaultClientConnection extends SocketHttpClientConnection
} }
targetHost = target; targetHost = target;
connSecure = secure; connSecure = secure;
}
} // update
@Override @Override
public HttpResponse receiveResponseHeader() throws HttpException, IOException { public HttpResponse receiveResponseHeader() throws HttpException, IOException {
@ -248,7 +234,6 @@ public class DefaultClientConnection extends SocketHttpClientConnection
return response; return response;
} }
@Override @Override
public void sendRequestHeader(HttpRequest request) throws HttpException, IOException { public void sendRequestHeader(HttpRequest request) throws HttpException, IOException {
super.sendRequestHeader(request); super.sendRequestHeader(request);
@ -261,4 +246,4 @@ public class DefaultClientConnection extends SocketHttpClientConnection
} }
} }
} // class DefaultClientConnection }

View File

@ -51,29 +51,29 @@ import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.scheme.SocketFactory; import org.apache.http.conn.scheme.SocketFactory;
/** /**
* Default implementation of a * Default implementation of a {@link ClientConnectionOperator}. It uses
* {@link ClientConnectionOperator ClientConnectionOperator}. * a {@link SchemeRegistry} to look up {@link SocketFactory} objects.
* It uses a {@link SchemeRegistry SchemeRegistry} to look up * <p>
* {@link SocketFactory SocketFactory} objects. * 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>
* <!-- empty lines to avoid svn diff problems --> * <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
* @version $Revision$ $Date$ * <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 * @since 4.0
*/ */
@ThreadSafe @ThreadSafe
public class DefaultClientConnectionOperator public class DefaultClientConnectionOperator implements ClientConnectionOperator {
implements ClientConnectionOperator {
/** The scheme registry for looking up socket factories. */ /** The scheme registry for looking up socket factories. */
protected final SchemeRegistry schemeRegistry; // @ThreadSafe protected final SchemeRegistry schemeRegistry; // @ThreadSafe
/** /**
* Creates a new client connection operator for the given scheme registry. * Creates a new client connection operator for the given scheme registry.
* *
@ -87,14 +87,10 @@ public class DefaultClientConnectionOperator
schemeRegistry = schemes; schemeRegistry = schemes;
} }
// non-javadoc, see interface ClientConnectionOperator
public OperatedClientConnection createConnection() { public OperatedClientConnection createConnection() {
return new DefaultClientConnection(); return new DefaultClientConnection();
} }
// non-javadoc, see interface ClientConnectionOperator
public void openConnection(OperatedClientConnection conn, public void openConnection(OperatedClientConnection conn,
HttpHost target, HttpHost target,
InetAddress local, InetAddress local,
@ -136,10 +132,8 @@ public class DefaultClientConnectionOperator
} }
prepareSocket(sock, context, params); prepareSocket(sock, context, params);
conn.openCompleted(sf.isSecure(sock), params); conn.openCompleted(sf.isSecure(sock), params);
} // openConnection }
// non-javadoc, see interface ClientConnectionOperator
public void updateSecureConnection(OperatedClientConnection conn, public void updateSecureConnection(OperatedClientConnection conn,
HttpHost target, HttpHost target,
HttpContext context, HttpContext context,
@ -155,7 +149,6 @@ public class DefaultClientConnectionOperator
throw new IllegalArgumentException throw new IllegalArgumentException
("Target host must not be null."); ("Target host must not be null.");
} }
//@@@ is context allowed to be null?
if (params == null) { if (params == null) {
throw new IllegalArgumentException throw new IllegalArgumentException
("Parameters must not be null."); ("Parameters must not be null.");
@ -182,10 +175,7 @@ public class DefaultClientConnectionOperator
} }
prepareSocket(sock, context, params); prepareSocket(sock, context, params);
conn.update(sock, target, lsf.isSecure(sock), 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. * Performs standard initializations on a newly created socket.
@ -200,9 +190,6 @@ public class DefaultClientConnectionOperator
HttpParams params) HttpParams params)
throws IOException { throws IOException {
// context currently not used, but derived classes may need it
//@@@ is context allowed to be null?
sock.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params)); sock.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
sock.setSoTimeout(HttpConnectionParams.getSoTimeout(params)); sock.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
@ -210,9 +197,7 @@ public class DefaultClientConnectionOperator
if (linger >= 0) { if (linger >= 0) {
sock.setSoLinger(linger > 0, linger); sock.setSoLinger(linger > 0, linger);
} }
}
} // prepareSocket }
} // class DefaultClientConnectionOperator

View File

@ -48,13 +48,19 @@ import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.params.ConnRouteParams; import org.apache.http.conn.params.ConnRouteParams;
/** /**
* Default implementation of an {@link HttpRoutePlanner}. * Default implementation of an {@link HttpRoutePlanner}. This implementation
* This implementation is based on * is based on {@link org.apache.http.conn.params.ConnRoutePNames parameters}.
* {@link org.apache.http.conn.params.ConnRoutePNames parameters}. * It will not make use of any Java system properties, nor of system or
* It will not make use of any Java system properties, * browser proxy settings.
* 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 * @since 4.0
*/ */
@ -64,7 +70,6 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
/** The scheme registry. */ /** The scheme registry. */
protected final SchemeRegistry schemeRegistry; // class is @ThreadSafe protected final SchemeRegistry schemeRegistry; // class is @ThreadSafe
/** /**
* Creates a new default route planner. * Creates a new default route planner.
* *
@ -78,8 +83,6 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
schemeRegistry = schreg; schemeRegistry = schreg;
} }
// non-javadoc, see interface HttpRoutePlanner
public HttpRoute determineRoute(HttpHost target, public HttpRoute determineRoute(HttpHost target,
HttpRequest request, HttpRequest request,
HttpContext context) HttpContext context)
@ -122,5 +125,4 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
return route; return route;
} }
} }

View File

@ -52,7 +52,16 @@ import org.apache.http.params.HttpParams;
import org.apache.http.util.CharArrayBuffer; 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 * @since 4.0
*/ */
@ThreadSafe // no public methods @ThreadSafe // no public methods

View File

@ -63,6 +63,13 @@ import org.apache.http.conn.params.ConnRouteParams;
* {@link org.apache.http.conn.params.ConnRoutePNames parameters}, * {@link org.apache.http.conn.params.ConnRoutePNames parameters},
* though not the {@link * though not the {@link
* org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}. * 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 * @since 4.0
*/ */
@ -75,7 +82,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
/** The proxy selector to use, or <code>null</code> for system default. */ /** The proxy selector to use, or <code>null</code> for system default. */
protected ProxySelector proxySelector; protected ProxySelector proxySelector;
/** /**
* Creates a new proxy selector route planner. * Creates a new proxy selector route planner.
* *
@ -94,7 +100,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
proxySelector = prosel; proxySelector = prosel;
} }
/** /**
* Obtains the proxy selector to use. * Obtains the proxy selector to use.
* *
@ -104,7 +109,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
return this.proxySelector; return this.proxySelector;
} }
/** /**
* Sets the proxy selector to use. * Sets the proxy selector to use.
* *
@ -115,9 +119,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
this.proxySelector = prosel; this.proxySelector = prosel;
} }
// non-javadoc, see interface HttpRoutePlanner
public HttpRoute determineRoute(HttpHost target, public HttpRoute determineRoute(HttpHost target,
HttpRequest request, HttpRequest request,
HttpContext context) HttpContext context)
@ -160,7 +161,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
return route; return route;
} }
/** /**
* Determines a proxy for the given target. * Determines a proxy for the given target.
* *
@ -211,7 +211,6 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
return result; return result;
} }
/** /**
* Obtains a host from an {@link InetSocketAddress}. * 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. * Chooses a proxy from a list of available proxies.
* The default implementation just picks the first non-SOCKS proxy * The default implementation just picks the first non-SOCKS proxy
* from the list. If there are only SOCKS proxies, * 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 request the request to be sent, never <code>null</code>
* @param context the context, or <code>null</code> * @param context the context, or <code>null</code>
* *
* @return a proxy of type {@link Proxy.Type#DIRECT DIRECT} * @return a proxy type
* or {@link Proxy.Type#HTTP HTTP}, never <code>null</code>
*/ */
protected Proxy chooseProxy(List<Proxy> proxies, protected Proxy chooseProxy(List<Proxy> proxies,
HttpHost target, HttpHost target,
@ -290,5 +287,5 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
return result; return result;
} }
} // class ProxySelectorRoutePlanner }