Index: trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
===================================================================
--- trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java (revision 380929)
+++ trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java (working copy)
@@ -182,12 +182,12 @@
}
//@@@ behavior if proxying - set real target or proxy, or both?
- this.defaultContext.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST,
+ this.defaultContext.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST,
conn.getTargetHost());
this.defaultContext.setAttribute(HttpExecutionContext.HTTP_CONNECTION,
conn);
- prepareRequest(request, this.defaultContext);
+ doPrepareRequest(request, this.defaultContext);
this.defaultContext.setAttribute(HttpExecutionContext.HTTP_REQUEST,
request);
@@ -197,10 +197,12 @@
// returns false or a non-recoverable exception is thrown
for (int execCount = 0; ; execCount++) {
try {
- establishConnection(conn, conn.getTargetHost(), request.getParams());
- response = sendRequest(request, conn, this.defaultContext);
+ doEstablishConnection(conn, conn.getTargetHost(),
+ request.getParams());
+ response = doSendRequest(request, conn, this.defaultContext);
if (response == null) {
- response = receiveResponse(request, conn, this.defaultContext);
+ response = doReceiveResponse(request, conn,
+ this.defaultContext);
}
// exit retry loop
break;
@@ -221,7 +223,7 @@
}
}
- finishResponse(response, this.defaultContext);
+ doFinishResponse(response, this.defaultContext);
return response;
@@ -236,7 +238,7 @@
* @throws HttpException in case of a protocol or processing problem
* @throws IOException in case of an I/O problem
*/
- protected void prepareRequest(
+ protected void doPrepareRequest(
final HttpRequest request,
final HttpContext context)
throws HttpException, IOException {
@@ -262,7 +264,7 @@
* @throws HttpException in case of a problem
* @throws IOException in case of an IO problem
*/
- protected void establishConnection(
+ protected void doEstablishConnection(
final HttpClientConnection conn,
final HttpHost target,
final HttpParams params)
@@ -302,22 +304,25 @@
/**
* Send a request over a connection.
- * This method also handles the expect-continue handshake, if requested.
+ * This method also handles the expect-continue handshake if necessary.
+ * If it does not have to handle an expect-continue handshake, it will
+ * not use the connection for reading or anything else that depends on
+ * data coming in over the connection.
*
* @param request the request to send, already
- * {@link #prepareRequest prepared}
+ * {@link #doPrepareRequest prepared}
* @param conn the connection over which to send the request, already
- * {@link #establishConnection established}
+ * {@link #doEstablishConnection established}
* @param context the context for sending the request
*
* @return a terminal response received as part of an expect-continue
- * handshake or null if the expect-continue handshake
- * is not used.
+ * handshake, or
+ * null if the expect-continue handshake is not used
*
* @throws HttpException in case of a protocol or processing problem
* @throws IOException in case of an I/O problem
*/
- protected HttpResponse sendRequest(
+ protected HttpResponse doSendRequest(
final HttpRequest request,
final HttpClientConnection conn,
final HttpContext context)
@@ -337,14 +342,16 @@
conn.sendRequestHeader(request);
if (request instanceof HttpEntityEnclosingRequest) {
- HttpEntityEnclosingRequest entityEnclRequest = (HttpEntityEnclosingRequest) request;
+ HttpEntityEnclosingRequest entityEnclRequest =
+ (HttpEntityEnclosingRequest) request;
// Check for expect-continue handshake. We have to flush the
// headers and wait for an 100-continue response to handle it.
// If we get a different response, we must not send the entity.
boolean sendentity = true;
final HttpVersion ver = request.getRequestLine().getHttpVersion();
- if (entityEnclRequest.expectContinue() && ver.greaterEquals(HttpVersion.HTTP_1_1)) {
+ if (entityEnclRequest.expectContinue() &&
+ ver.greaterEquals(HttpVersion.HTTP_1_1)) {
conn.flush();
// As suggested by RFC 2616 section 8.2.3, we don't wait for a
@@ -377,17 +384,19 @@
/**
* Wait for and receive a response.
+ * This method will automatically ignore intermediate responses
+ * with status code 1xx.
*
* @param request the request for which to obtain the response
* @param conn the connection over which the request was sent
* @param context the context for receiving the response
*
- * @return the response, not yet post-processed
+ * @return the final response, not yet post-processed
*
* @throws HttpException in case of a protocol or processing problem
* @throws IOException in case of an I/O problem
*/
- protected HttpResponse receiveResponse(
+ protected HttpResponse doReceiveResponse(
final HttpRequest request,
final HttpClientConnection conn,
final HttpContext context)
@@ -401,7 +410,7 @@
if (context == null) {
throw new IllegalArgumentException("HTTP context may not be null");
}
- // see HttpRequestExecutor.doExecute, final part
+
HttpResponse response = null;
int statuscode = 0;
@@ -417,7 +426,7 @@
return response;
- } // obtainResponse
+ }
/**
* Finish a response.
@@ -432,7 +441,7 @@
* @throws HttpException in case of a protocol or processing problem
* @throws IOException in case of an I/O problem
*/
- protected void finishResponse(
+ protected void doFinishResponse(
final HttpResponse response,
final HttpContext context)
throws HttpException, IOException {
Index: trunk/http-async/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java
===================================================================
--- trunk/http-async/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java (revision 380929)
+++ trunk/http-async/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java (working copy)
@@ -380,10 +380,10 @@
}
//@@@ TODO: retry handling!
- transmitRequest(async_processor,
- handle.getRequest(),
- handle.getContext(),
- client_connection);
+ transmitRequestTo(async_processor,
+ handle.getRequest(),
+ handle.getContext(),
+ client_connection);
//@@@ TODO: timeout handling!
HttpResponse response =
Index: trunk/http-async/src/java/org/apache/http/async/AbstractHttpDispatcher.java
===================================================================
--- trunk/http-async/src/java/org/apache/http/async/AbstractHttpDispatcher.java (revision 380929)
+++ trunk/http-async/src/java/org/apache/http/async/AbstractHttpDispatcher.java (working copy)
@@ -118,7 +118,8 @@
/**
* Prepare a request for sending.
- * Maps to {@link AsyncHttpProcessor#prepareRequest proc.prepareRequest}.
+ * Maps to
+ * {@link AsyncHttpProcessor#doPrepareRequest proc.doPrepareRequest}.
*
* @param proc the processor to use for preparing
* @param request the request to prepare
@@ -137,14 +138,16 @@
HttpContext context)
throws HttpException, IOException {
- return proc.prepareRequest(request, target, context);
+ return proc.asyncPrepareRequest(request, target, context);
} // prepareRequest
/**
- * Send a request.
- * Maps to {@link AsyncHttpProcessor#transmitRequest proc.transmitRequest}.
+ * Establishe a connection and send a request.
+ * Maps to
+ * {@link AsyncHttpProcessor#asyncSendRequest
+ * proc.asyncSendRequest}.
*
* @param proc the processor to use for transmission
* @param request the request to send, already prepared
@@ -156,20 +159,21 @@
* @throws HttpException in case of a problem
* @throws IOException in case of an IO problem
*/
- protected static void transmitRequest(AsyncHttpProcessor proc,
- HttpRequest request,
- HttpContext context,
- HttpClientConnection connection)
+ protected static void transmitRequestTo(AsyncHttpProcessor proc,
+ HttpRequest request,
+ HttpContext context,
+ HttpClientConnection connection)
throws HttpException, IOException {
- proc.transmitRequest(request, context, connection);
+ proc.asyncSendRequest(request, connection, context);
- } // transmitRequest
+ } // transmitRequestTo
/**
* Wait for and receive a response.
- * Maps to {@link AsyncHttpProcessor#obtainResponse proc.obtainResponse}.
+ * Maps to
+ * {@link AsyncHttpProcessor#doReceiveResponse proc.doReceiveResponse}.
*
* @param proc the processor to use for transmission
* @param request the request for which to obtain the response
@@ -182,19 +186,20 @@
*/
protected static
HttpResponse obtainResponse(AsyncHttpProcessor proc,
- HttpRequest request,
- HttpContext context,
- HttpClientConnection connection)
+ HttpRequest request,
+ HttpContext context,
+ HttpClientConnection connection)
throws HttpException, IOException {
- return proc.obtainResponse(request, context, connection);
+ return proc.doReceiveResponse(request, connection, context);
} // obtainResponse
/**
* Finish a response.
- * Maps to {@link AsyncHttpProcessor#finishResponse proc.finishResponse}.
+ * Maps to
+ * {@link AsyncHttpProcessor#doFinishResponse proc.doFinishResponse}.
*
* @param response the response object to finish
* @param context the context obtained from
@@ -205,11 +210,11 @@
* @throws IOException in case of an IO problem
*/
protected static void finishResponse(AsyncHttpProcessor proc,
- HttpResponse response,
+ HttpResponse response,
HttpContext context)
throws HttpException, IOException {
- proc.finishResponse(response, context);
+ proc.doFinishResponse(response, context);
} // finishResponse
Index: trunk/http-async/src/java/org/apache/http/async/AsyncHttpProcessor.java
===================================================================
--- trunk/http-async/src/java/org/apache/http/async/AsyncHttpProcessor.java (revision 380929)
+++ trunk/http-async/src/java/org/apache/http/async/AsyncHttpProcessor.java (working copy)
@@ -84,41 +84,41 @@
* @throws HttpException if the request can not be prepared
* @throws IOException in case of an IO problem
*/
- protected HttpContext prepareRequest(HttpRequest request,
- HttpHost target,
- HttpContext context)
+ protected HttpContext asyncPrepareRequest(HttpRequest request,
+ HttpHost target,
+ HttpContext context)
throws HttpException, IOException {
HttpExecutionContext hxc = new HttpExecutionContext(context);
hxc.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST,
- target);
+ target);
// argument checking is done here...
- super.prepareRequest(request, hxc);
+ super.doPrepareRequest(request, hxc);
hxc.setAttribute(HttpExecutionContext.HTTP_REQUEST,
- request);
+ request);
return hxc;
- } // prepareRequest
+ } // asyncPrepareRequest
/**
- * Send a request.
+ * Establish a connection and send a request.
*
* @param request the request to send, already prepared
+ * @param connection the connection over which to send the request
* @param context the request specific context returned by
- * {@link #prepareRequest prepareRequest}
+ * {@link #asyncPrepareRequest asyncPrepareRequest}
* when the request was prepared
- * @param connection the connection over which to send the request
*
* @throws HttpException in case of a problem
* @throws IOException in case of an IO problem
*/
- protected void transmitRequest(HttpRequest request,
- HttpContext context,
- HttpClientConnection connection)
+ protected void asyncSendRequest(HttpRequest request,
+ HttpClientConnection connection,
+ HttpContext context)
throws HttpException, IOException {
if (request == null)
@@ -135,17 +135,18 @@
("target host missing in request context");
}
if (request instanceof HttpEntityEnclosingRequest
- && ((HttpEntityEnclosingRequest)request).expectContinue()) {
- throw new ProtocolException("Expect-continue handshake not supported");
+ && ((HttpEntityEnclosingRequest)request).expectContinue()) {
+ throw new ProtocolException
+ ("Expect-continue handshake not supported");
}
- super.establishConnection(connection, target, request.getParams());
+ super.doEstablishConnection(connection, target, request.getParams());
context.setAttribute(HttpExecutionContext.HTTP_CONNECTION,
- connection);
+ connection);
- super.sendRequest(request, connection, context);
+ super.doSendRequest(request, connection, context);
- } // transmitRequest
+ } // asyncSendRequest
/**
@@ -153,6 +154,9 @@
*
* @param request the request for which to obtain the response
* @param connection the connection over which the request was sent
+ * @param context the request specific context returned by
+ * {@link #asyncPrepareRequest asyncPrepareRequest}
+ * when the request was prepared
*
* @return the response, not yet post-processed
*
@@ -160,15 +164,15 @@
* @throws IOException in case of an IO problem
*/
protected
- HttpResponse obtainResponse(HttpRequest request,
- HttpContext context,
- HttpClientConnection connection)
+ HttpResponse doReceiveResponse(HttpRequest request,
+ HttpClientConnection connection,
+ HttpContext context)
throws HttpException, IOException {
// argument checking is done here...
- return super.receiveResponse(request, connection, context);
+ return super.doReceiveResponse(request, connection, context);
- } // obtainResponse
+ } // doReceiveResponse
/**
@@ -179,20 +183,20 @@
*
* @param response the response object to finish
* @param context the context obtained from
- * {@link #prepareRequest prepareRequest}
+ * {@link #asyncPrepareRequest asyncPrepareRequest}
* for the matching request
*
* @throws HttpException in case of a problem
* @throws IOException in case of an IO problem
*/
- protected void finishResponse(HttpResponse response,
- HttpContext context)
+ protected void doFinishResponse(HttpResponse response,
+ HttpContext context)
throws HttpException, IOException {
// argument checking is done here...
- super.finishResponse(response, context);
+ super.doFinishResponse(response, context);
- } // finishResponse
+ } // doFinishResponse
} // class AsyncHttpProcessor