[prev in list] [next in list] [prev in thread] [next in thread]
List: httpcomponents-commits
Subject: svn commit: r449756 - in /jakarta/httpcomponents/httpcore/trunk:
From: rolandw () apache ! org
Date: 2006-09-25 17:48:16
Message-ID: 20060925174817.4AF5A1A981A () eris ! apache ! org
[Download RAW message or body]
Author: rolandw
Date: Mon Sep 25 10:48:15 2006
New Revision: 449756
URL: http://svn.apache.org/viewvc?view=rev&rev=449756
Log:
HTTPCORE-13, take 1 plus JavaDoc fixes
Added:
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/protocol/
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/protocol/DefaultHttpProcessor.java
- copied, changed from r449665, \
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/AbstractHttpProcessor.java
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java \
(with props) Removed:
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/AbstractHttpProcessor.java
Modified:
jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/package.html
jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/examples/org/apache/http/examples/ElementalHttpGet.java?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java \
Mon Sep 25 10:48:15 2006 @@ -40,6 +40,7 @@
import org.apache.http.impl.DefaultHttpClientConnection;
import org.apache.http.impl.DefaultHttpParams;
import org.apache.http.impl.io.PlainSocketFactory;
+import org.apache.http.impl.protocol.DefaultHttpProcessor;
import org.apache.http.io.SocketFactory;
import org.apache.http.message.HttpGet;
import org.apache.http.params.HttpParams;
@@ -75,16 +76,18 @@
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "Jakarta-HttpComponents/1.1");
HttpProtocolParams.setUseExpectContinue(params, true);
-
- HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
- httpexecutor.setParams(params);
+
+ DefaultHttpProcessor httpproc = new DefaultHttpProcessor();
// Required protocol interceptors
- httpexecutor.addInterceptor(new RequestContent());
- httpexecutor.addInterceptor(new RequestTargetHost());
+ httpproc.addInterceptor(new RequestContent());
+ httpproc.addInterceptor(new RequestTargetHost());
// Recommended protocol interceptors
- httpexecutor.addInterceptor(new RequestConnControl());
- httpexecutor.addInterceptor(new RequestUserAgent());
- httpexecutor.addInterceptor(new RequestExpectContinue());
+ httpproc.addInterceptor(new RequestConnControl());
+ httpproc.addInterceptor(new RequestUserAgent());
+ httpproc.addInterceptor(new RequestExpectContinue());
+
+ HttpRequestExecutor httpexecutor = new HttpRequestExecutor(httpproc);
+ httpexecutor.setParams(params);
HttpContext context = new HttpExecutionContext(null);
Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/examples/org/apache/http/examples/ElementalHttpPost.java?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java \
Mon Sep 25 10:48:15 2006 @@ -45,6 +45,7 @@
import org.apache.http.impl.DefaultHttpClientConnection;
import org.apache.http.impl.DefaultHttpParams;
import org.apache.http.impl.io.PlainSocketFactory;
+import org.apache.http.impl.protocol.DefaultHttpProcessor;
import org.apache.http.io.SocketFactory;
import org.apache.http.message.HttpPost;
import org.apache.http.params.HttpParams;
@@ -81,16 +82,18 @@
HttpProtocolParams.setUserAgent(params, "Jakarta-HttpComponents/1.1");
HttpProtocolParams.setUseExpectContinue(params, true);
- HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
- httpexecutor.setParams(params);
+ DefaultHttpProcessor httpproc = new DefaultHttpProcessor();
// Required protocol interceptors
- httpexecutor.addInterceptor(new RequestContent());
- httpexecutor.addInterceptor(new RequestTargetHost());
+ httpproc.addInterceptor(new RequestContent());
+ httpproc.addInterceptor(new RequestTargetHost());
// Recommended protocol interceptors
- httpexecutor.addInterceptor(new RequestConnControl());
- httpexecutor.addInterceptor(new RequestUserAgent());
- httpexecutor.addInterceptor(new RequestExpectContinue());
+ httpproc.addInterceptor(new RequestConnControl());
+ httpproc.addInterceptor(new RequestUserAgent());
+ httpproc.addInterceptor(new RequestExpectContinue());
+ HttpRequestExecutor httpexecutor = new HttpRequestExecutor(httpproc);
+ httpexecutor.setParams(params);
+
HttpContext context = new HttpExecutionContext(null);
HttpHost host = new HttpHost("localhost", 8080);
Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/examples/org/apache/http/examples/ElementalHttpServer.java?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java \
Mon Sep 25 10:48:15 2006 @@ -50,6 +50,7 @@
import org.apache.http.entity.FileEntity;
import org.apache.http.impl.DefaultHttpParams;
import org.apache.http.impl.DefaultHttpServerConnection;
+import org.apache.http.impl.protocol.DefaultHttpProcessor;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
@@ -177,12 +178,14 @@
System.out.println("Incoming connection from " + \
socket.getInetAddress()); conn.bind(socket, this.params);
- // Set up HTTP service
- HttpService httpService = new HttpService();
- httpService.addInterceptor(new ResponseDate());
- httpService.addInterceptor(new ResponseServer()); \
- httpService.addInterceptor(new ResponseContent());
- httpService.addInterceptor(new ResponseConnControl());
+ // Set up HTTP processor and service
+ DefaultHttpProcessor httpproc = new DefaultHttpProcessor();
+ httpproc.addInterceptor(new ResponseDate());
+ httpproc.addInterceptor(new ResponseServer());
+ httpproc.addInterceptor(new ResponseContent());
+ httpproc.addInterceptor(new ResponseConnControl());
+
+ HttpService httpService = new HttpService(httpproc);
httpService.setParams(this.params);
httpService.registerRequestHandler("*", new HttpFileHandler());
Copied: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/protocol/DefaultHttpProcessor.java \
(from r449665, jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/AbstractHttpProcessor.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/main/java/org/apache/http/impl/protocol/DefaultHttpProcessor.java?view=diff&rev=4497 \
56&p1=jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ \
protocol/AbstractHttpProcessor.java&r1=449665&p2=jakarta/httpcomponents/httpcore/trunk \
/module-main/src/main/java/org/apache/http/impl/protocol/DefaultHttpProcessor.java&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/AbstractHttpProcessor.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/protocol/DefaultHttpProcessor.java \
Mon Sep 25 10:48:15 2006 @@ -27,7 +27,7 @@
*
*/
-package org.apache.http.protocol;
+package org.apache.http.impl.protocol;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,6 +39,9 @@
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+
/**
* Keeps lists of interceptors for processing requests and responses.
@@ -49,7 +52,7 @@
*
* @since 4.0
*/
-public abstract class AbstractHttpProcessor {
+public class DefaultHttpProcessor implements HttpProcessor {
private List requestInterceptors = null;
private List responseInterceptors = null;
@@ -146,7 +149,7 @@
this.responseInterceptors = null;
}
- protected void preprocessRequest(
+ public void preprocessRequest(
final HttpRequest request,
final HttpContext context)
throws IOException, HttpException {
@@ -158,7 +161,7 @@
}
}
- protected void postprocessResponse(
+ public void postprocessResponse(
final HttpResponse response,
final HttpContext context)
throws IOException, HttpException {
Added: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java?view=auto&rev=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java \
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java \
Mon Sep 25 10:48:15 2006 @@ -0,0 +1,90 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.protocol;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseInterceptor;
+
+/**
+ * Performs interceptor processing of requests and responses.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
+ *
+ * @version $Revision$
+ *
+ * @since 4.0
+ */
+public interface HttpProcessor {
+
+ /**
+ * Preprocesses a request.
+ * On the client side, this step is performed before the request is
+ * sent to the server. On the server side, this step is performed
+ * on incoming messages before the message body is evaluated.
+ *
+ * @param request the request to preprocess
+ * @param context the context for the request
+ *
+ * @throws IOException in case of an IO problem
+ * @throws HttpException in case of a protocol or other problem
+ */
+ void preprocessRequest(HttpRequest request,
+ HttpContext context)
+ throws IOException, HttpException
+ ;
+
+
+ /**
+ * Preprocesses a request.
+ * On the client side, this step is performed before the request is
+ * sent to the server. On the server side, this step is performed
+ * on incoming messages before the message body is evaluated.
+ *
+ * @param response the response to postprocess
+ * @param context the context for the request
+ *
+ * @throws IOException in case of an IO problem
+ * @throws HttpException in case of a protocol or other problem
+ */
+ void postprocessResponse(HttpResponse response,
+ HttpContext context)
+ throws IOException, HttpException
+ ;
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/main/java/org/apache/http/protocol/HttpRequestExecutor.java?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java \
Mon Sep 25 10:48:15 2006 @@ -52,17 +52,24 @@
*
* @since 4.0
*/
-public class HttpRequestExecutor extends AbstractHttpProcessor {
+public class HttpRequestExecutor {
protected static final int WAIT_FOR_CONTINUE_MS = 10000;
- private HttpParams params = null;
+ private HttpParams params;
+ private final HttpProcessor processor;
/**
* Create a new request executor.
+ *
+ * @param proc the processor to use on requests and responses
*/
- public HttpRequestExecutor() {
- super();
+ public HttpRequestExecutor(HttpProcessor proc) {
+ if (proc == null)
+ throw new IllegalArgumentException
+ ("HTTP processor must not be null.");
+
+ this.processor = proc;
}
/**
@@ -179,7 +186,7 @@
}
// link default parameters
request.getParams().setDefaults(this.params);
- preprocessRequest(request, context);
+ processor.preprocessRequest(request, context);
}
/**
@@ -333,7 +340,7 @@
if (context == null) {
throw new IllegalArgumentException("HTTP context may not be null");
}
- postprocessResponse(response, context);
+ processor.postprocessResponse(response, context);
}
} // class HttpRequestExecutor
Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/main/java/org/apache/http/protocol/HttpService.java?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java \
Mon Sep 25 10:48:15 2006 @@ -58,16 +58,26 @@
*
* @version $Revision$
*/
-public class HttpService extends AbstractHttpProcessor {
+public class HttpService {
private HttpParams params = null;
+ private final HttpProcessor processor;
private ConnectionReuseStrategy connStrategy = null;
private HttpResponseFactory responseFactory = null;
private final Map handlerMap;
- public HttpService() {
- super();
+ /**
+ * Create a new HTTP service.
+ *
+ * @param proc the processor to use on requests and responses
+ */
+ public HttpService(HttpProcessor proc) {
+ if (proc == null)
+ throw new IllegalArgumentException
+ ("HTTP processor must not be null.");
+
+ this.processor = proc;
this.handlerMap = new HashMap();
this.connStrategy = new DefaultConnectionReuseStrategy();
this.responseFactory = new DefaultHttpResponseFactory();
@@ -159,7 +169,7 @@
}
conn.receiveRequestEntity((HttpEntityEnclosingRequest) request);
}
- preprocessRequest(request, context);
+ processor.preprocessRequest(request, context);
context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
@@ -178,7 +188,7 @@
response.getParams().setDefaults(this.params);
handleException(ex, response);
}
- postprocessResponse(response, context);
+ processor.postprocessResponse(response, context);
conn.sendResponseHeader(response);
conn.sendResponseEntity(response);
conn.flush();
Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/package.html
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/sr \
c/main/java/org/apache/http/protocol/package.html?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/package.html \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/package.html \
Mon Sep 25 10:48:15 2006 @@ -45,8 +45,8 @@
some of the headers before sending a message, and interprets
headers when a message has been received.
<br/>
-An HTTP {@link org.apache.http.protocol.AbstractHttpProcessor processor}
-keeps lists of so-called interceptors that will be executed
+An HTTP {@link org.apache.http.protocol.HttpProcessor processor}
+typically keeps lists of so-called interceptors that will be executed
before a message is sent and after it has been received.
An application should initialize a processor, set up the lists
with the required and desired processors, and then communicate
Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/or \
g/apache/http/contrib/benchmark/BenchmarkWorker.java?view=diff&rev=449756&r1=449755&r2=449756
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java \
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java \
Mon Sep 25 10:48:15 2006 @@ -42,6 +42,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpClientConnection;
+import org.apache.http.impl.protocol.DefaultHttpProcessor;
import org.apache.http.io.SocketFactory;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
@@ -79,15 +80,18 @@
super();
this.params = params;
this.context = new HttpExecutionContext(null);
- this.httpexecutor = new HttpRequestExecutor();
+
+ DefaultHttpProcessor httpproc = new DefaultHttpProcessor();
+ this.httpexecutor = new HttpRequestExecutor(httpproc);
this.httpexecutor.setParams(params);
+
// Required request interceptors
- this.httpexecutor.addInterceptor(new RequestContent());
- this.httpexecutor.addInterceptor(new RequestTargetHost());
+ httpproc.addInterceptor(new RequestContent());
+ httpproc.addInterceptor(new RequestTargetHost());
// Recommended request interceptors
- this.httpexecutor.addInterceptor(new RequestConnControl());
- this.httpexecutor.addInterceptor(new RequestUserAgent());
- this.httpexecutor.addInterceptor(new RequestExpectContinue());
+ httpproc.addInterceptor(new RequestConnControl());
+ httpproc.addInterceptor(new RequestUserAgent());
+ httpproc.addInterceptor(new RequestExpectContinue());
this.connstrategy = new DefaultConnectionReuseStrategy();
this.verbosity = verbosity;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic