hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r630662 - in /httpcomponents/httpcore/trunk: module-main/src/main/java/org/apache/http/protocol/ module-nio/src/examples/org/apache/http/examples/nio/ module-nio/src/main/java/org/apache/http/nio/ module-nio/src/main/java/org/apache/http/ni...
Date Sun, 24 Feb 2008 19:40:56 GMT
Author: olegk
Date: Sun Feb 24 11:40:51 2008
New Revision: 630662

URL: http://svn.apache.org/viewvc?rev=630662&view=rev
Log:
HTTPCORE-148: Merged code contributed by Sam Berlin up to the trunk


Added:
    httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-main/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/ContentDecoderChannel.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/ContentDecoderChannel.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/BufferingNHttpEntity.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/BufferingNHttpEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ConsumingNHttpEntity.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/ConsumingNHttpEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ConsumingNHttpEntityTemplate.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/ConsumingNHttpEntityTemplate.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ProducingNHttpEntity.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/ProducingNHttpEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AbstractNHttpClientHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/AbstractNHttpClientHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AbstractNHttpServiceHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/AbstractNHttpServiceHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestExecutionHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestExecutionHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerResolver.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerResolver.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpResponseTrigger.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpResponseTrigger.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/SimpleNHttpRequestHandlerResolver.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/test/java/org/apache/http/mockup/SimpleNHttpRequestHandlerResolver.java
    httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
      - copied unchanged from r630661, httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
Modified:
    httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
    httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ByteArrayNIOEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/FileNIOEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/HttpNIOEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/StringNIOEntity.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java
    httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestAllProtocol.java

Modified: httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java (original)
+++ httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java Sun Feb 24 11:40:51 2008
@@ -31,12 +31,10 @@
 
 package org.apache.http.protocol;
 
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
- * Maintains a map of HTTP request handlers keyed by a request URI pattern. 
+ * Maintains a map of HTTP request handlers keyed by a request URI pattern.
  * {@link HttpRequestHandler} instances can be looked up by request URI
  * using the {@link HttpRequestHandlerResolver} interface.<br/>
  * Patterns may have three formats:
@@ -52,77 +50,33 @@
  */
 public class HttpRequestHandlerRegistry implements HttpRequestHandlerResolver {
 
-    private final Map handlerMap;
-    
+    private final UriPatternMatcher matcher;
+
     public HttpRequestHandlerRegistry() {
-        super();
-        this.handlerMap = new HashMap();
+        matcher = new UriPatternMatcher();
     }
-    
+
     public void register(final String pattern, final HttpRequestHandler handler) {
-        if (pattern == null) {
-            throw new IllegalArgumentException("URI request pattern may not be null");
-        }
-        if (handler == null) {
-            throw new IllegalArgumentException("HTTP request handelr may not be null");
-        }
-        this.handlerMap.put(pattern, handler);
+        matcher.register(pattern, handler);
     }
-    
+
     public void unregister(final String pattern) {
-        if (pattern == null) {
-            return;
-        }
-        this.handlerMap.remove(pattern);
+        matcher.unregister(pattern);
     }
-    
+
     public void setHandlers(final Map map) {
-        if (map == null) {
-            throw new IllegalArgumentException("Map of handlers may not be null");
-        }
-        this.handlerMap.clear();
-        this.handlerMap.putAll(map);
-    }
-    
-    public HttpRequestHandler lookup(String requestURI) {
-        if (requestURI == null) {
-            throw new IllegalArgumentException("Request URI may not be null");
-        }
-        //Strip away the query part part if found
-        int index = requestURI.indexOf("?");
-        if (index != -1) {
-            requestURI = requestURI.substring(0, index);
-        }
-        
-        // direct match?
-        Object handler = this.handlerMap.get(requestURI);
-        if (handler == null) {
-            // pattern match?
-            String bestMatch = null;
-            for (Iterator it = this.handlerMap.keySet().iterator(); it.hasNext();) {
-                String pattern = (String) it.next();
-                if (matchUriRequestPattern(pattern, requestURI)) {
-                    // we have a match. is it any better?
-                    if (bestMatch == null 
-                            || (bestMatch.length() < pattern.length())
-                            || (bestMatch.length() == pattern.length() && pattern.endsWith("*"))) {
-                        handler = this.handlerMap.get(pattern);
-                        bestMatch = pattern;
-                    }
-                }
-            }
-        }
-        return (HttpRequestHandler) handler;
+        matcher.setHandlers(map);
     }
 
+    public HttpRequestHandler lookup(final String requestURI) {
+        return (HttpRequestHandler) matcher.lookup(requestURI);
+    }
+
+    /**
+     * @deprecated
+     */
     protected boolean matchUriRequestPattern(final String pattern, final String requestUri) {
-        if (pattern.equals("*")) {
-            return true;
-        } else {
-            return 
-            (pattern.endsWith("*") && requestUri.startsWith(pattern.substring(0, pattern.length() - 1))) ||
-            (pattern.startsWith("*") && requestUri.endsWith(pattern.substring(1, pattern.length())));
-        }
+        return matcher.matchUriRequestPattern(pattern, requestUri);
     }
-    
+
 }

Modified: httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java Sun Feb 24 11:40:51 2008
@@ -31,60 +31,49 @@
 package org.apache.http.examples.nio;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.io.RandomAccessFile;
-import java.io.UnsupportedEncodingException;
 import java.net.InetSocketAddress;
 import java.net.URLDecoder;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
 
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.Header;
-import org.apache.http.HttpConnection;
-import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
 import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultServerIOEventDispatch;
 import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
 import org.apache.http.nio.ContentDecoder;
-import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.ContentDecoderChannel;
 import org.apache.http.nio.FileContentDecoder;
-import org.apache.http.nio.FileContentEncoder;
-import org.apache.http.nio.NHttpServerConnection;
-import org.apache.http.nio.NHttpServiceHandler;
-import org.apache.http.nio.entity.ByteArrayNIOEntity;
-import org.apache.http.nio.entity.FileNIOEntity;
-import org.apache.http.nio.entity.HttpNIOEntity;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.NHttpConnection;
+import org.apache.http.nio.entity.ConsumingNHttpEntity;
+import org.apache.http.nio.entity.ConsumingNHttpEntityTemplate;
+import org.apache.http.nio.entity.ContentListener;
+import org.apache.http.nio.entity.NFileEntity;
+import org.apache.http.nio.entity.NStringEntity;
+import org.apache.http.nio.protocol.AsyncNHttpServiceHandler;
+import org.apache.http.nio.protocol.EventListener;
+import org.apache.http.nio.protocol.NHttpRequestHandler;
+import org.apache.http.nio.protocol.NHttpRequestHandlerResolver;
+import org.apache.http.nio.protocol.SimpleNHttpRequestHandler;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.ListeningIOReactor;
 import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.params.DefaultedHttpParams;
 import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.ExecutionContext;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.ResponseConnControl;
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
-import org.apache.http.util.EncodingUtils;
 
 public class NHttpFileServer {
 
@@ -93,6 +82,7 @@
             System.err.println("Please specify document root directory");
             System.exit(1);
         }
+
         boolean useFileChannels = true;
         if (args.length >= 2) {
             String s = args[1];
@@ -100,19 +90,44 @@
                 useFileChannels = false;
             }
         }
+
         HttpParams params = new BasicHttpParams();
         params
-            .setIntParameter(HttpConnectionParams.SO_TIMEOUT, 20000)
-            .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
-            .setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false)
-            .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true)
-            .setParameter(HttpProtocolParams.ORIGIN_SERVER, "HttpComponents/1.1");
+            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 20000)
+            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
+            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
+            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
+            .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");
 
-        ListeningIOReactor ioReactor = new DefaultListeningIOReactor(2, params);
+        BasicHttpProcessor httpproc = new BasicHttpProcessor();
+        httpproc.addInterceptor(new ResponseDate());
+        httpproc.addInterceptor(new ResponseServer());
+        httpproc.addInterceptor(new ResponseContent());
+        httpproc.addInterceptor(new ResponseConnControl());
+
+        AsyncNHttpServiceHandler handler = new AsyncNHttpServiceHandler(
+                httpproc,
+                new DefaultHttpResponseFactory(),
+                new DefaultConnectionReuseStrategy(),
+                params);
+
+        final HttpFileHandler filehandler = new HttpFileHandler(args[0], useFileChannels);
+
+        NHttpRequestHandlerResolver resolver = new NHttpRequestHandlerResolver() {
+
+            public NHttpRequestHandler lookup(String requestURI) {
+                return filehandler;
+            }
+
+        };
+
+        handler.setHandlerResolver(resolver);
+
+        // Provide an event logger
+        handler.setEventListener(new EventLogger());
 
-        NHttpServiceHandler handler = new FileServiceHandler(args[0], useFileChannels, params);
         IOEventDispatch ioEventDispatch = new DefaultServerIOEventDispatch(handler, params);
-        
+        ListeningIOReactor ioReactor = new DefaultListeningIOReactor(2, params);
         try {
             ioReactor.listen(new InetSocketAddress(8080));
             ioReactor.execute(ioEventDispatch);
@@ -124,429 +139,111 @@
         System.out.println("Shutdown");
     }
 
-    private static final String CONN_STATE    = "http.conn-state";
-    
-    static class ConnState {
-
-        private final ByteBuffer inbuf;
-        private final ByteBuffer outbuf;
-        
-        private File fileHandle;
-        private RandomAccessFile inputFile;
-        private WritableByteChannel inputChannel;
-        private ReadableByteChannel outputChannel;
-        private long inputCount;
-        private long outputCount;
-        
-        public ConnState() {
-            super();
-            this.inbuf = ByteBuffer.allocateDirect(2048);
-            this.outbuf = ByteBuffer.allocateDirect(2048);
-        }
-
-        public ByteBuffer getInbuf() {
-            return this.inbuf;
-        }
-
-        public ByteBuffer getOutbuf() {
-            return this.outbuf;
-        }
-
-        public File getInputFile() throws IOException {
-            if (this.fileHandle == null) {
-                this.fileHandle = File.createTempFile("tmp", ".tmp", null);
-            }
-            return this.fileHandle;
-        }
-        
-        public WritableByteChannel getInputChannel() throws IOException {
-            if (this.inputFile == null) {
-                this.inputFile = new RandomAccessFile(getInputFile(), "rw");
-            }
-            if (this.inputChannel == null) {
-                this.inputChannel = this.inputFile.getChannel();
-            }
-            return this.inputChannel;
-        }
-        
-        public void setOutputChannel(final ReadableByteChannel channel) {
-            this.outputChannel = channel;
-        }
-        
-        public ReadableByteChannel getOutputChannel() {
-            return this.outputChannel;
-        }
-        
-        public long getInputCount() {
-            return this.inputCount;
-        }
-        
-        public void incrementInputCount(long count) {
-            this.inputCount += count;
-        }
-        
-        public long getOutputCount() {
-            return this.outputCount;
-        }
-        
-        public void incrementOutputCount(long count) {
-            this.outputCount += count;
-        }
-        
-        public void reset() throws IOException {
-            this.inbuf.clear();
-            this.outbuf.clear();
-            this.inputCount = 0;
-            this.outputCount = 0;
-            if (this.inputChannel != null) {
-                this.inputChannel.close();
-                this.inputChannel = null;
-            }
-            if (this.inputFile != null) {
-                this.inputFile.close();
-                this.inputFile = null;
-            }
-            if (this.fileHandle != null) {
-                this.fileHandle.delete();
-                this.fileHandle = null;
-            }
-        }
-        
-    }
-    
-    public static class FileServiceHandler implements NHttpServiceHandler {
+    static class HttpFileHandler extends SimpleNHttpRequestHandler {
 
         private final String docRoot;
-        private boolean useFileChannels;
-        private final HttpParams params;
-        private final HttpResponseFactory responseFactory;
-        private final HttpProcessor httpProcessor;
-        private final ConnectionReuseStrategy connStrategy;
-        
-        public FileServiceHandler(
-                final String docRoot, 
-                boolean useFileChannels, 
-                final HttpParams params) {
-            super();
+        private final boolean useFileChannels;
+
+        public HttpFileHandler(final String docRoot, boolean useFileChannels) {
             this.docRoot = docRoot;
             this.useFileChannels = useFileChannels;
-            this.params = params;
-            this.responseFactory = new DefaultHttpResponseFactory();
-            this.httpProcessor = createProtocolProcessor();
-            this.connStrategy = new DefaultConnectionReuseStrategy();
-        }
-
-        private HttpProcessor createProtocolProcessor() {
-            BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
-            httpProcessor.addInterceptor(new ResponseDate());
-            httpProcessor.addInterceptor(new ResponseServer());                    
-            httpProcessor.addInterceptor(new ResponseContent());
-            httpProcessor.addInterceptor(new ResponseConnControl());
-            return httpProcessor;
-        }
-        
-        public void connected(final NHttpServerConnection conn) {
-            System.out.println("New incoming connection");
-            
-            HttpContext context = conn.getContext();
-            ConnState connState = new ConnState();
-            
-            context.setAttribute(CONN_STATE, connState);
-        }
-
-        public void closed(final NHttpServerConnection conn) {
-            System.out.println("Connection closed");
-            HttpContext context = conn.getContext();
-
-            ConnState connState = (ConnState) context.getAttribute(CONN_STATE);
-            try {
-                connState.reset();
-            } catch (IOException ex) {
-                System.err.println("I/O error: " + ex.getMessage());
-            }
-            context.setAttribute(CONN_STATE, null);
         }
 
-        public void timeout(final NHttpServerConnection conn) {
-            System.err.println("Timeout");
-            shutdownConnection(conn);
-        }
-        
-        public void exception(final NHttpServerConnection conn, final IOException ex) {
-            System.err.println("I/O error: " + ex.getMessage());
-            shutdownConnection(conn);
+        public ConsumingNHttpEntity entityRequest(
+                final HttpEntityEnclosingRequest request,
+                final HttpContext context) throws HttpException, IOException {
+            return new ConsumingNHttpEntityTemplate(
+                    request.getEntity(),
+                    new FileWriteListener(useFileChannels));
         }
 
-        public void exception(final NHttpServerConnection conn, final HttpException ex) {
-            if (conn.isResponseSubmitted()) {
-                System.err.println("Unexpected HTTP protocol error: " + ex.getMessage());
-                return;
-            }
-            
-            HttpContext context = conn.getContext();
-
-            ConnState connState = (ConnState) context.getAttribute(CONN_STATE);
-            
-            HttpResponse response =  this.responseFactory.newHttpResponse(
-                    HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST, context);
-            response.setParams(
-                    new DefaultedHttpParams(response.getParams(), this.params));
-            
-            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
-            context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-            
-            try {
-                handleException(ex, response, context);
-                this.httpProcessor.process(response, context);
-                commitResponse(conn, connState, response);
-            } catch (HttpException ex2) {
-                shutdownConnection(conn);
-                System.err.println("Unexpected HTTP protocol error: " + ex2.getMessage());
-            } catch (IOException ex2) {
-                shutdownConnection(conn);
-                System.err.println("I/O error: " + ex2.getMessage());
+        public void handle(
+                final HttpRequest request,
+                final HttpResponse response,
+                final HttpContext context) throws HttpException, IOException {
+            String target = request.getRequestLine().getUri();
+            final File file = new File(this.docRoot, URLDecoder.decode(target, "UTF-8"));
+            if (!file.exists()) {
+                response.setStatusCode(HttpStatus.SC_NOT_FOUND);
+                NStringEntity entity = new NStringEntity("<html><body><h1>File" +
+                        file.getPath() + " not found</h1></body></html>", "UTF-8");
+                entity.setContentType("text/html; charset=UTF-8");
+                response.setEntity(entity);
+            } else if (!file.canRead() || file.isDirectory()) {
+                response.setStatusCode(HttpStatus.SC_FORBIDDEN);
+                NStringEntity entity = new NStringEntity("<html><body><h1>Access denied</h1></body></html>", "UTF-8");
+                entity.setContentType("text/html; charset=UTF-8");
+                response.setEntity(entity);
+            } else {
+                response.setStatusCode(HttpStatus.SC_OK);
+                NFileEntity entity = new NFileEntity(file, "text/html", useFileChannels);
+                response.setEntity(entity);
             }
         }
 
-        private void shutdownConnection(final HttpConnection conn) {
-            try {
-                conn.shutdown();
-            } catch (IOException ignore) {
-            }
-        }
-        
-        public void requestReceived(final NHttpServerConnection conn) {
-            HttpContext context = conn.getContext();
-            
-            ConnState connState = (ConnState) context.getAttribute(CONN_STATE);
-            
-            HttpRequest request = conn.getHttpRequest();
-            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
+    }
 
-            try {
-                connState.reset();
+    static class FileWriteListener implements ContentListener {
+        private final File file;
+        private final FileInputStream inputFile;
+        private final FileChannel fileChannel;
+        private final boolean useFileChannels;
+        private long idx = 0;
+
+        public FileWriteListener(boolean useFileChannels) throws IOException {
+            this.file = File.createTempFile("tmp", ".tmp", null);
+            this.inputFile = new FileInputStream(file);
+            this.fileChannel = inputFile.getChannel();
+            this.useFileChannels = useFileChannels;
+        }
 
-                if (request instanceof HttpEntityEnclosingRequest) {
-                    
-                    HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
-                    if (eeRequest.expectContinue()) {
-                        HttpResponse ack = this.responseFactory.newHttpResponse(
-                                ver, 100, context);
-                        conn.submitResponse(ack);
-                    }
-                    // Wait until the request content is fully received
-                } else {
-                    // No request content is expected. 
-                    // Proceed with service right away
-                    doService(conn, connState);
-                }
-            } catch (HttpException ex) {
-                shutdownConnection(conn);
-                System.err.println("Unexpected HTTP protocol error: " + ex.getMessage());
-            } catch (IOException ex) {
-                shutdownConnection(conn);
-                System.err.println("I/O error: " + ex.getMessage());
+        public void contentAvailable(ContentDecoder decoder, IOControl ioctrl)
+                throws IOException {
+            long transferred;
+            if(useFileChannels && decoder instanceof FileContentDecoder) {
+                transferred = ((FileContentDecoder) decoder).transfer(
+                        fileChannel, idx, Long.MAX_VALUE);
+            } else {
+                transferred = fileChannel.transferFrom(
+                        new ContentDecoderChannel(decoder), idx, Long.MAX_VALUE);
             }
-        }
 
-        public void responseReady(final NHttpServerConnection conn) {
+            if(transferred > 0)
+                idx += transferred;
         }
 
-        public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) {
-            HttpContext context = conn.getContext();
-
-            ConnState connState = (ConnState) context.getAttribute(
-                    CONN_STATE);
+        public void finished() {
             try {
-
-                WritableByteChannel channel = connState.getInputChannel();
-                long transferred;
-
-                // Test if the decoder is capable of direct transfer to file
-                if (this.useFileChannels && 
-                        decoder instanceof FileContentDecoder && 
-                        channel instanceof FileChannel) {
-                    long pos = connState.getInputCount();
-                    transferred = ((FileContentDecoder) decoder).transfer(
-                            (FileChannel) channel, pos, Integer.MAX_VALUE);
-                } else {
-                    ByteBuffer buf = connState.getInbuf();
-                    decoder.read(buf);
-                    buf.flip();
-                    transferred = channel.write(buf);
-                    buf.compact();
-                }
-                connState.incrementInputCount(transferred);
-                
-                if (decoder.isCompleted()) {
-                    // Request entity has been fully received
-                    channel.close();
-                    doService(conn, connState);
-                }
-                
-            } catch (HttpException ex) {
-                shutdownConnection(conn);
-                System.err.println("Unexpected HTTP protocol error: " + ex.getMessage());
-            } catch (IOException ex) {
-                shutdownConnection(conn);
-                System.err.println("I/O error: " + ex.getMessage());
-            }
-        }
-
-        public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder) {
-            HttpContext context = conn.getContext();
-
-            ConnState connState = (ConnState) context.getAttribute(
-                    CONN_STATE);
-            HttpResponse response = conn.getHttpResponse();
+                inputFile.close();
+            } catch(IOException ignored) {}
             try {
+                fileChannel.close();
+            } catch(IOException ignored) {}
+        }
+    }
 
-                ReadableByteChannel channel = connState.getOutputChannel();
-                long transferred;
+    static class EventLogger implements EventListener {
 
-                // Test if the encoder is capable of direct transfer from file
-                if (this.useFileChannels && 
-                        encoder instanceof FileContentEncoder && 
-                        channel instanceof FileChannel) {
-                    long pos = connState.getOutputCount();
-                    transferred = ((FileContentEncoder) encoder).transfer(
-                            (FileChannel) channel, pos, Integer.MAX_VALUE);
-                } else {
-                    ByteBuffer outbuf = connState.getOutbuf();
-                    transferred = channel.read(outbuf);
-                    if (transferred != -1) {
-                        outbuf.flip();
-                        encoder.write(outbuf);
-                        outbuf.compact();
-                    }
-                }
-                if (transferred == -1) {
-                    encoder.complete();
-                }
-                if (transferred > 0) {
-                    connState.incrementOutputCount(transferred);
-                }
-                
-                if (encoder.isCompleted()) {
-                    channel.close();
-                    if (!this.connStrategy.keepAlive(response, context)) {
-                        conn.close();
-                    }
-                }
-            
-            } catch (IOException ex) {
-                shutdownConnection(conn);
-                System.err.println("I/O error: " + ex.getMessage());
-            }
+        public void connectionOpen(final NHttpConnection conn) {
+            System.out.println("Connection open: " + conn);
         }
 
-        private void commitResponse(
-                final NHttpServerConnection conn,
-                final ConnState connState,
-                final HttpResponse response) throws HttpException, IOException {
-            
-            HttpEntity entity = response.getEntity();
-            if (entity != null) {
-                ReadableByteChannel channel;
-                if (entity instanceof HttpNIOEntity) {
-                    channel = ((HttpNIOEntity) entity).getChannel();
-                } else {
-                    channel = Channels.newChannel(entity.getContent());
-                }
-                connState.setOutputChannel(channel);
-            }
-            conn.submitResponse(response);
+        public void connectionTimeout(final NHttpConnection conn) {
+            System.out.println("Connection timed out: " + conn);
         }
 
-        private void doService(
-                final NHttpServerConnection conn,
-                final ConnState connState) throws HttpException, IOException {
-            HttpContext context = conn.getContext();
-            HttpRequest request = conn.getHttpRequest();
-            request.setParams(
-                    new DefaultedHttpParams(request.getParams(), this.params));
-
-            if (request instanceof HttpEntityEnclosingRequest) {
-                HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
-                Header h = request.getFirstHeader(HTTP.CONTENT_TYPE);
-                String contentType = null;
-                if (h != null) {
-                    contentType = h.getValue();
-                }
-                HttpNIOEntity entity = new FileNIOEntity(connState.getInputFile(), contentType);
-                eeRequest.setEntity(entity);
-            }
-            
-            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
-            HttpResponse response =  this.responseFactory.newHttpResponse(ver, 200, context);
-            response.setParams(
-                    new DefaultedHttpParams(response.getParams(), this.params));
-            
-            context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
-            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
-            context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-
-            try {
-                this.httpProcessor.process(request, context);
-                handleRequest(request, response, context);
-            } catch (HttpException ex) {
-                handleException(ex, response, context);
-            }
-            this.httpProcessor.process(response, context);
-            commitResponse(conn, connState, response);
+        public void connectionClosed(final NHttpConnection conn) {
+            System.out.println("Connection closed: " + conn);
         }
-        
-        private void handleRequest(
-                final HttpRequest request, 
-                final HttpResponse response,
-                final HttpContext context) {
-
-            String target = request.getRequestLine().getUri();
-            File file;
-            try {
-                file = new File(this.docRoot, URLDecoder.decode(target, "UTF-8"));
-            } catch (UnsupportedEncodingException ex) {
-                throw new Error("UTF-8 not supported");
-            }
 
-            if (!file.exists()) {
-                
-                response.setStatusCode(HttpStatus.SC_NOT_FOUND);
-                byte[] msg = EncodingUtils.getAsciiBytes(
-                        file.getName() + ": not found");
-                ByteArrayNIOEntity entity = new ByteArrayNIOEntity(msg);
-                entity.setContentType("text/plain; charset=US-ASCII");
-                response.setEntity(entity);
-                
-            } else if (!file.canRead() || file.isDirectory()) {
-
-                response.setStatusCode(HttpStatus.SC_FORBIDDEN);
-                byte[] msg = EncodingUtils.getAsciiBytes(
-                        file.getName() + ": access denied");
-                ByteArrayNIOEntity entity = new ByteArrayNIOEntity(msg);
-                entity.setContentType("text/plain; charset=US-ASCII");
-                response.setEntity(entity);
-
-            } else {
-
-                FileNIOEntity entity = new FileNIOEntity(file, "text/html");
-                response.setEntity(entity);
-                
-            }
+        public void fatalIOException(final IOException ex, final NHttpConnection conn) {
+            System.err.println("I/O error: " + ex.getMessage());
         }
-     
-        private void handleException(
-                final HttpException ex, 
-                final HttpResponse response,
-                final HttpContext context) {
-            response.setStatusLine(HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST);
-            byte[] msg = EncodingUtils.getAsciiBytes(
-                    "Malformed HTTP request: " + ex.getMessage());
-            ByteArrayNIOEntity entity = new ByteArrayNIOEntity(msg);
-            entity.setContentType("text/plain; charset=US-ASCII");
-            response.setEntity(entity);
+
+        public void fatalProtocolException(final HttpException ex, final NHttpConnection conn) {
+            System.err.println("HTTP error: " + ex.getMessage());
         }
-        
+
     }
 
 }

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ByteArrayNIOEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ByteArrayNIOEntity.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ByteArrayNIOEntity.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ByteArrayNIOEntity.java Sun Feb 24 11:40:51 2008
@@ -1,7 +1,7 @@
 /*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -45,10 +45,11 @@
  *
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
- * @version $Revision:$
+ * @version $Revision$
  * 
  * @since 4.0
  */
+@Deprecated
 public class ByteArrayNIOEntity extends ByteArrayEntity implements HttpNIOEntity {
 
     public ByteArrayNIOEntity(final byte[] b) {

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/FileNIOEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/FileNIOEntity.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/FileNIOEntity.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/FileNIOEntity.java Sun Feb 24 11:40:51 2008
@@ -1,7 +1,7 @@
 /*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -46,10 +46,11 @@
  *
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
- * @version $Revision:$
+ * @version $Revision$
  * 
  * @since 4.0
  */
+@Deprecated
 public class FileNIOEntity extends FileEntity implements HttpNIOEntity {
 
     public FileNIOEntity(final File file, final String contentType) {

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/HttpNIOEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/HttpNIOEntity.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/HttpNIOEntity.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/HttpNIOEntity.java Sun Feb 24 11:40:51 2008
@@ -36,6 +36,7 @@
 
 import org.apache.http.HttpEntity;
 
+@Deprecated
 public interface HttpNIOEntity extends HttpEntity  {
 
     ReadableByteChannel getChannel() throws IOException;

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/StringNIOEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/StringNIOEntity.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/StringNIOEntity.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/StringNIOEntity.java Sun Feb 24 11:40:51 2008
@@ -1,7 +1,7 @@
 /*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -46,10 +46,11 @@
  *
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
- * @version $Revision:$
+ * @version $Revision$
  * 
  * @since 4.0
  */
+@Deprecated
 public class StringNIOEntity extends StringEntity implements HttpNIOEntity {
 
     public StringNIOEntity(

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java Sun Feb 24 11:40:51 2008
@@ -36,18 +36,16 @@
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpException;
 import org.apache.http.nio.NHttpClientConnection;
-import org.apache.http.nio.NHttpClientHandler;
 import org.apache.http.nio.util.ByteBufferAllocator;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpProcessor;
 
-public abstract class NHttpClientHandlerBase extends NHttpHandlerBase 
-                                             implements NHttpClientHandler {
+public abstract class NHttpClientHandlerBase extends AbstractNHttpClientHandler {
 
     protected HttpRequestExecutionHandler execHandler;
-    
+
     public NHttpClientHandlerBase(
-            final HttpProcessor httpProcessor, 
+            final HttpProcessor httpProcessor,
             final HttpRequestExecutionHandler execHandler,
             final ConnectionReuseStrategy connStrategy,
             final ByteBufferAllocator allocator,
@@ -58,7 +56,7 @@
         }
         this.execHandler = execHandler;
     }
-    
+
     public void closed(final NHttpClientConnection conn) {
         if (this.eventListener != null) {
             this.eventListener.connectionClosed(conn);
@@ -78,5 +76,5 @@
             this.eventListener.fatalIOException(ex, conn);
         }
     }
-    
+
 }

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java Sun Feb 24 11:40:51 2008
@@ -34,7 +34,6 @@
 import java.io.IOException;
 
 import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpConnection;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -46,16 +45,16 @@
 public abstract class NHttpHandlerBase {
 
     protected static final String CONN_STATE = "http.nio.conn-state";
-    
+
     protected final HttpProcessor httpProcessor;
     protected final ConnectionReuseStrategy connStrategy;
     protected final ByteBufferAllocator allocator;
     protected final HttpParams params;
-    
+
     protected EventListener eventListener;
-    
+
     public NHttpHandlerBase(
-            final HttpProcessor httpProcessor, 
+            final HttpProcessor httpProcessor,
             final ConnectionReuseStrategy connStrategy,
             final ByteBufferAllocator allocator,
             final HttpParams params) {
@@ -81,12 +80,12 @@
     public HttpParams getParams() {
         return this.params;
     }
-    
+
     public void setEventListener(final EventListener eventListener) {
         this.eventListener = eventListener;
     }
 
-    protected void closeConnection(final HttpConnection conn, final Throwable cause) {
+    protected void closeConnection(final NHttpConnection conn, final Throwable cause) {
         try {
             // Try to close it nicely
             conn.close();
@@ -98,14 +97,14 @@
             }
         }
     }
-    
-    protected void shutdownConnection(final HttpConnection conn, final Throwable cause) {
+
+    protected void shutdownConnection(final NHttpConnection conn, final Throwable cause) {
         try {
             conn.shutdown();
         } catch (IOException ignore) {
         }
     }
-    
+
     protected void handleTimeout(final NHttpConnection conn) {
         try {
             if (conn.getStatus() == NHttpConnection.ACTIVE) {
@@ -124,19 +123,19 @@
         } catch (IOException ignore) {
         }
     }
-    
+
     protected boolean canResponseHaveBody(
             final HttpRequest request, final HttpResponse response) {
 
         if (request != null && "HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
             return false;
         }
-        
-        int status = response.getStatusLine().getStatusCode(); 
-        return status >= HttpStatus.SC_OK 
-            && status != HttpStatus.SC_NO_CONTENT 
+
+        int status = response.getStatusLine().getStatusCode();
+        return status >= HttpStatus.SC_OK
+            && status != HttpStatus.SC_NO_CONTENT
             && status != HttpStatus.SC_NOT_MODIFIED
-            && status != HttpStatus.SC_RESET_CONTENT; 
+            && status != HttpStatus.SC_RESET_CONTENT;
     }
-    
+
 }

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java Sun Feb 24 11:40:51 2008
@@ -31,67 +31,36 @@
 
 package org.apache.http.nio.protocol;
 
-import java.io.IOException;
-
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpResponseFactory;
-import org.apache.http.nio.NHttpServerConnection;
-import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.util.ByteBufferAllocator;
-import org.apache.http.nio.util.HeapByteBufferAllocator;
 import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpExpectationVerifier;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpRequestHandlerResolver;
 
-public abstract class NHttpServiceHandlerBase extends NHttpHandlerBase
-                                              implements NHttpServiceHandler {
-
-    protected final HttpResponseFactory responseFactory;
+public abstract class NHttpServiceHandlerBase extends AbstractNHttpServiceHandler {
 
     protected HttpRequestHandlerResolver handlerResolver;
-    protected HttpExpectationVerifier expectationVerifier;
-    
+
     public NHttpServiceHandlerBase(
-            final HttpProcessor httpProcessor, 
+            final HttpProcessor httpProcessor,
             final HttpResponseFactory responseFactory,
             final ConnectionReuseStrategy connStrategy,
             final ByteBufferAllocator allocator,
             final HttpParams params) {
-        super(httpProcessor, connStrategy, allocator, params);
-        if (responseFactory == null) {
-            throw new IllegalArgumentException("Response factory may not be null");
-        }
-        this.responseFactory = responseFactory;
+        super(httpProcessor, responseFactory, connStrategy, allocator, params);
     }
 
     public NHttpServiceHandlerBase(
-            final HttpProcessor httpProcessor, 
+            final HttpProcessor httpProcessor,
             final HttpResponseFactory responseFactory,
             final ConnectionReuseStrategy connStrategy,
             final HttpParams params) {
-        this(httpProcessor, responseFactory, connStrategy, 
-                new HeapByteBufferAllocator(), params);
+        super(httpProcessor, responseFactory, connStrategy, params);
     }
-    
+
     public void setHandlerResolver(final HttpRequestHandlerResolver handlerResolver) {
         this.handlerResolver = handlerResolver;
     }
 
-    public void setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) {
-        this.expectationVerifier = expectationVerifier;
-    }
-
-    public void exception(final NHttpServerConnection conn, final IOException ex) {
-        shutdownConnection(conn, ex);
-        
-        if (this.eventListener != null) {
-            this.eventListener.fatalIOException(ex, conn);
-        }
-    }
-
-    public void timeout(final NHttpServerConnection conn) {
-        handleTimeout(conn);
-    }
-    
 }

Modified: httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestAllProtocol.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestAllProtocol.java?rev=630662&r1=630661&r2=630662&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestAllProtocol.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestAllProtocol.java Sun Feb 24 11:40:51 2008
@@ -43,6 +43,7 @@
         suite.addTest(TestBufferingNHttpHandlers.suite());
         suite.addTest(TestThrottlingNHttpHandler.suite());
         suite.addTest(TestNIOSSLHttp.suite());
+        suite.addTest(TestAsyncNHttpHandlers.suite());
         return suite;
     }
 



Mime
View raw message