hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r562518 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src: main/java/org/apache/http/impl/nio/ main/java/org/apache/http/impl/nio/codecs/ main/java/org/apache/http/nio/ test/java/org/apache/http/impl/nio/codecs/
Date Fri, 03 Aug 2007 16:38:23 GMT
Author: olegk
Date: Fri Aug  3 09:38:19 2007
New Revision: 562518

URL: http://svn.apache.org/viewvc?view=rev&rev=562518
Log:
HTTPCORE-106: 
* Introduced NHttpMessageParser and NHttpMessageWriter interfaces for non-blocking connections
* Factored out HTTP message parsing and writing code into separate classes making it possible
to plug in an alternative implementation of those classes

Added:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
      - copied, changed from r560528, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpMessageParser.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
  (with props)
Removed:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpMessageParser.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?view=diff&rev=562518&r1=562517&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
Fri Aug  3 09:38:19 2007
@@ -32,21 +32,19 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
-import java.util.Iterator;
 
-import org.apache.http.Header;
 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.message.BasicHeader;
-import org.apache.http.message.BasicRequestLine;
-import org.apache.http.message.BufferedHeader;
+import org.apache.http.impl.nio.codecs.HttpRequestWriter;
+import org.apache.http.impl.nio.codecs.HttpResponseParser;
 import org.apache.http.nio.NHttpClientConnection;
 import org.apache.http.nio.NHttpClientHandler;
-import org.apache.http.impl.nio.codecs.HttpResponseParser;
+import org.apache.http.nio.NHttpMessageParser;
+import org.apache.http.nio.NHttpMessageWriter;
 import org.apache.http.nio.reactor.EventMask;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.util.ByteBufferAllocator;
@@ -55,7 +53,8 @@
 public class DefaultNHttpClientConnection 
     extends NHttpConnectionBase implements NHttpClientConnection {
 
-    private HttpResponseParser responseParser;
+    private NHttpMessageParser responseParser;
+    private NHttpMessageWriter requestWriter;
     
     public DefaultNHttpClientConnection(
             final IOSession session,
@@ -67,6 +66,7 @@
             throw new IllegalArgumentException("Response factory may not be null");
         }
         this.responseParser = new HttpResponseParser(this.inbuf, responseFactory, params);
+        this.requestWriter = new HttpRequestWriter(this.outbuf, params);
         this.hasBufferedInput = false;
         this.hasBufferedOutput = false;
         this.session.setBufferStatus(this);
@@ -81,6 +81,7 @@
     public void resetOutput() {
         this.request = null;
         this.contentEncoder = null;
+        this.requestWriter.reset();
     }
     
     public void consumeInput(final NHttpClientHandler handler) {
@@ -181,22 +182,7 @@
         if (this.request != null) {
             throw new HttpException("Request already submitted");
         }
-        this.lineBuffer.clear();
-        BasicRequestLine.format(this.lineBuffer, request.getRequestLine());
-        this.outbuf.writeLine(this.lineBuffer);
-        for (Iterator it = request.headerIterator(); it.hasNext(); ) {
-            Header header = (Header) it.next();
-            if (header instanceof BufferedHeader) {
-                // If the header is backed by a buffer, re-use the buffer
-                this.outbuf.writeLine(((BufferedHeader)header).getBuffer());
-            } else {
-                this.lineBuffer.clear();
-                BasicHeader.format(this.lineBuffer, header);
-                this.outbuf.writeLine(this.lineBuffer);
-            }
-        }
-        this.lineBuffer.clear();
-        this.outbuf.writeLine(this.lineBuffer);
+        this.requestWriter.write(request);
 
         if (request instanceof HttpEntityEnclosingRequest) {
             prepareEncoder(request);

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?view=diff&rev=562518&r1=562517&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
Fri Aug  3 09:38:19 2007
@@ -32,21 +32,19 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
-import java.util.Iterator;
 
-import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
 import org.apache.http.HttpResponse;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.message.BufferedHeader;
+import org.apache.http.impl.nio.codecs.HttpRequestParser;
+import org.apache.http.impl.nio.codecs.HttpResponseWriter;
+import org.apache.http.nio.NHttpMessageParser;
+import org.apache.http.nio.NHttpMessageWriter;
 import org.apache.http.nio.NHttpServerConnection;
 import org.apache.http.nio.NHttpServiceHandler;
-import org.apache.http.impl.nio.codecs.HttpRequestParser;
 import org.apache.http.nio.reactor.EventMask;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.util.ByteBufferAllocator;
@@ -55,7 +53,8 @@
 public class DefaultNHttpServerConnection 
     extends NHttpConnectionBase implements NHttpServerConnection {
 
-    private HttpRequestParser requestParser;
+    private NHttpMessageParser requestParser;
+    private NHttpMessageWriter responseWriter;
     
     public DefaultNHttpServerConnection(
             final IOSession session,
@@ -67,6 +66,7 @@
             throw new IllegalArgumentException("Request factory may not be null");
         }
         this.requestParser = new HttpRequestParser(this.inbuf, requestFactory, params);
+        this.responseWriter = new HttpResponseWriter(this.outbuf, params);
     }
 
     public void resetInput() {
@@ -78,6 +78,7 @@
     public void resetOutput() {
         this.response = null;
         this.contentEncoder = null;
+        this.responseWriter.reset();
     }
     
     public void consumeInput(final NHttpServiceHandler handler) {
@@ -180,22 +181,7 @@
         if (this.response != null) {
             throw new HttpException("Response already submitted");
         }
-        this.lineBuffer.clear();
-        BasicStatusLine.format(this.lineBuffer, response.getStatusLine());
-        this.outbuf.writeLine(this.lineBuffer);
-        for (Iterator it = response.headerIterator(); it.hasNext(); ) {
-            Header header = (Header) it.next();
-            if (header instanceof BufferedHeader) {
-                // If the header is backed by a buffer, re-use the buffer
-                this.outbuf.writeLine(((BufferedHeader)header).getBuffer());
-            } else {
-                this.lineBuffer.clear();
-                BasicHeader.format(this.lineBuffer, header);
-                this.outbuf.writeLine(this.lineBuffer);
-            }
-        }
-        this.lineBuffer.clear();
-        this.outbuf.writeLine(this.lineBuffer);
+        this.responseWriter.write(response);
 
         if (response.getStatusLine().getStatusCode() >= 200) {
             this.connMetrics.incrementRequestCount();

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?view=diff&rev=562518&r1=562517&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
Fri Aug  3 09:38:19 2007
@@ -71,7 +71,6 @@
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.SyncBasicHttpContext;
-import org.apache.http.util.CharArrayBuffer;
 
 public class NHttpConnectionBase 
         implements NHttpConnection, HttpInetConnection, SessionBufferStatus {
@@ -84,7 +83,6 @@
     
     protected final SessionInputBufferImpl inbuf;
     protected final SessionOutputBufferImpl outbuf;
-    protected final CharArrayBuffer lineBuffer;
     
     protected final HttpTransportMetricsImpl inTransportMetrics;
     protected final HttpTransportMetricsImpl outTransportMetrics;
@@ -121,7 +119,6 @@
         
         this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, allocator, params);

         this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, allocator,
params); 
-        this.lineBuffer = new CharArrayBuffer(64); 
         
         this.incomingContentStrategy = new LaxContentLengthStrategy();
         this.outgoingContentStrategy = new StrictContentLengthStrategy();

Copied: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
(from r560528, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpMessageParser.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java?view=diff&rev=562518&p1=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpMessageParser.java&r1=560528&p2=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpMessageParser.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
Fri Aug  3 09:38:19 2007
@@ -40,14 +40,15 @@
 import org.apache.http.HttpMessage;
 import org.apache.http.ProtocolException;
 import org.apache.http.message.BufferedHeader;
+import org.apache.http.nio.NHttpMessageParser;
 import org.apache.http.nio.reactor.SessionInputBuffer;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.CharArrayBuffer;
 
-public abstract class HttpMessageParser {
+public abstract class AbstractMessageParser implements NHttpMessageParser {
     
-    private final SessionInputBuffer buffer;    
+    private final SessionInputBuffer sessionBuffer;    
     
     private static final int READ_HEAD_LINE = 0;
     private static final int READ_HEADERS   = 1;
@@ -63,15 +64,15 @@
     private int maxLineLen = -1;
     private int maxHeaderCount = -1;
 
-    public HttpMessageParser(final SessionInputBuffer buffer, final HttpParams params) {
+    public AbstractMessageParser(final SessionInputBuffer buffer, final HttpParams params)
{
         super();
         if (buffer == null) {
             throw new IllegalArgumentException("Session input buffer may not be null");
         }
-        if (buffer == null) {
+        if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");
         }
-        this.buffer = buffer;
+        this.sessionBuffer = buffer;
         this.state = READ_HEAD_LINE;
         this.endOfStream = false;
         this.headerBufs = new ArrayList();        
@@ -81,9 +82,6 @@
                 HttpConnectionParams.MAX_HEADER_COUNT, -1);
     }
     
-    public void configure() {
-    }
-    
     public void reset() {
         this.state = READ_HEAD_LINE;
         this.endOfStream = false;
@@ -92,7 +90,7 @@
     }
     
     public int fillBuffer(final ReadableByteChannel channel) throws IOException {
-        int bytesRead = this.buffer.fill(channel);
+        int bytesRead = this.sessionBuffer.fill(channel);
         if (bytesRead == -1) {
             this.endOfStream = true;
         }
@@ -139,10 +137,10 @@
             } else {
                 this.lineBuf.clear();
             }
-            boolean lineComplete = this.buffer.readLine(this.lineBuf, this.endOfStream);
+            boolean lineComplete = this.sessionBuffer.readLine(this.lineBuf, this.endOfStream);
             if (this.maxLineLen > 0 && 
                     (this.lineBuf.length() > this.maxLineLen || 
-                            (!lineComplete && this.buffer.length() > this.maxLineLen)))
{
+                            (!lineComplete && this.sessionBuffer.length() > this.maxLineLen)))
{
                 throw new IOException("Maximum line length limit exceeded");
             }
             if (!lineComplete) {
@@ -166,7 +164,7 @@
                 }
                 break;
             }
-            if (this.endOfStream && !this.buffer.hasData()) {
+            if (this.endOfStream && !this.sessionBuffer.hasData()) {
                 this.state = COMPLETED;
             }
         }

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java?view=auto&rev=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
Fri Aug  3 09:38:19 2007
@@ -0,0 +1,89 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.impl.nio.codecs;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.http.Header;
+import org.apache.http.HttpException;
+import org.apache.http.HttpMessage;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BufferedHeader;
+import org.apache.http.nio.NHttpMessageWriter;
+import org.apache.http.nio.reactor.SessionOutputBuffer;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.CharArrayBuffer;
+
+public abstract class AbstractMessageWriter implements NHttpMessageWriter {
+    
+    private final SessionOutputBuffer sessionBuffer;    
+    private final CharArrayBuffer lineBuf;
+    
+    public AbstractMessageWriter(final SessionOutputBuffer buffer, final HttpParams params)
{
+        super();
+        if (buffer == null) {
+            throw new IllegalArgumentException("Session input buffer may not be null");
+        }
+        this.sessionBuffer = buffer;
+        this.lineBuf = new CharArrayBuffer(64); 
+    }
+    
+    public void reset() {
+    }
+    
+    protected abstract void writeHeadLine(CharArrayBuffer lineBuffer, HttpMessage message);
+
+    public void write(
+            final HttpMessage message) throws IOException, HttpException {
+        if (message == null) {
+            throw new IllegalArgumentException("HTTP message may not be null");
+        }
+        this.lineBuf.clear();
+        writeHeadLine(this.lineBuf, message);
+        this.sessionBuffer.writeLine(this.lineBuf);
+        for (Iterator it = message.headerIterator(); it.hasNext(); ) {
+            Header header = (Header) it.next();
+            if (header instanceof BufferedHeader) {
+                // If the header is backed by a buffer, re-use the buffer
+                this.sessionBuffer.writeLine(((BufferedHeader)header).getBuffer());
+            } else {
+                this.lineBuf.clear();
+                BasicHeader.format(this.lineBuf, header);
+                this.sessionBuffer.writeLine(this.lineBuf);
+            }
+        }
+        this.lineBuf.clear();
+        this.sessionBuffer.writeLine(this.lineBuf);
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java?view=diff&rev=562518&r1=562517&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java
Fri Aug  3 09:38:19 2007
@@ -40,7 +40,7 @@
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.CharArrayBuffer;
 
-public class HttpRequestParser extends HttpMessageParser {
+public class HttpRequestParser extends AbstractMessageParser {
     
     private final HttpRequestFactory requestFactory;
     

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java?view=auto&rev=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
Fri Aug  3 09:38:19 2007
@@ -0,0 +1,53 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.impl.nio.codecs;
+
+import org.apache.http.HttpMessage;
+import org.apache.http.HttpRequest;
+import org.apache.http.message.BasicRequestLine;
+import org.apache.http.nio.reactor.SessionOutputBuffer;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.CharArrayBuffer;
+
+public class HttpRequestWriter extends AbstractMessageWriter {
+
+    public HttpRequestWriter(final SessionOutputBuffer buffer, final HttpParams params) {
+        super(buffer, params);
+    }
+    
+    protected void writeHeadLine(
+            final CharArrayBuffer lineBuffer, 
+            final HttpMessage message) {
+        BasicRequestLine.format(lineBuffer, ((HttpRequest) message).getRequestLine());
+    }
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java?view=diff&rev=562518&r1=562517&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java
Fri Aug  3 09:38:19 2007
@@ -40,7 +40,7 @@
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.CharArrayBuffer;
 
-public class HttpResponseParser extends HttpMessageParser {
+public class HttpResponseParser extends AbstractMessageParser {
     
     private final HttpResponseFactory responseFactory;
     

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java?view=auto&rev=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
Fri Aug  3 09:38:19 2007
@@ -0,0 +1,53 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.impl.nio.codecs;
+
+import org.apache.http.HttpMessage;
+import org.apache.http.HttpResponse;
+import org.apache.http.message.BasicStatusLine;
+import org.apache.http.nio.reactor.SessionOutputBuffer;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.CharArrayBuffer;
+
+public class HttpResponseWriter extends AbstractMessageWriter {
+
+    public HttpResponseWriter(final SessionOutputBuffer buffer, final HttpParams params)
{
+        super(buffer, params);
+    }
+    
+    protected void writeHeadLine(
+            final CharArrayBuffer lineBuffer, 
+            final HttpMessage message) {
+        BasicStatusLine.format(lineBuffer, ((HttpResponse) message).getStatusLine());
+    }
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java?view=auto&rev=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
Fri Aug  3 09:38:19 2007
@@ -0,0 +1,59 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.nio;
+
+import java.io.IOException;
+import java.nio.channels.ReadableByteChannel;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpMessage;
+
+/**
+ * Abstract HTTP message parser for non-blocking connections.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface NHttpMessageParser {
+    
+    void reset();
+    
+    int fillBuffer(ReadableByteChannel channel) 
+        throws IOException;    
+
+    HttpMessage parse()
+        throws IOException, HttpException;
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java?view=auto&rev=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
Fri Aug  3 09:38:19 2007
@@ -0,0 +1,55 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.nio;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpMessage;
+
+/**
+ * Abstract HTTP message writer for non-blocking connections.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface NHttpMessageWriter {
+    
+    void reset();
+    
+    void write(HttpMessage message)
+        throws IOException, HttpException;
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java?view=diff&rev=562518&r1=562517&r2=562518
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
Fri Aug  3 09:38:19 2007
@@ -54,7 +54,7 @@
 import org.apache.http.params.HttpParams;
 
 /**
- * Simple tests for {@link HttpMessageParser}.
+ * Simple tests for {@link AbstractMessageParser}.
  *
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 



Mime
View raw message