hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r466204 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl: ExpandableBuffer.java SessionInputBuffer.java SessionOutputBuffer.java
Date Fri, 20 Oct 2006 17:01:47 GMT
Author: olegk
Date: Fri Oct 20 10:01:46 2006
New Revision: 466204

URL: http://svn.apache.org/viewvc?view=rev&rev=466204
Log:
Session buffers no longer throw I/O exceptions

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/ExpandableBuffer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionInputBuffer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionOutputBuffer.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/ExpandableBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/ExpandableBuffer.java?view=diff&rev=466204&r1=466203&r2=466204
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/ExpandableBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/ExpandableBuffer.java
Fri Oct 20 10:01:46 2006
@@ -101,5 +101,10 @@
         setOutputMode();
         return this.buffer.remaining();
     }
+    
+    protected void clear() {
+        this.buffer.clear();        
+        this.mode = INPUT_MODE;
+    }
         
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionInputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionInputBuffer.java?view=diff&rev=466204&r1=466203&r2=466204
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionInputBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionInputBuffer.java
Fri Oct 20 10:01:46 2006
@@ -37,7 +37,6 @@
 import java.nio.charset.CoderResult;
 
 import org.apache.http.io.CharArrayBuffer;
-import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HTTP;
@@ -47,7 +46,6 @@
     private CharBuffer charbuffer = null;
     private Charset charset = null;
     private CharsetDecoder chardecoder = null;
-    private int maxLineLen = -1;
     
     public SessionInputBuffer(int buffersize, int linebuffersize) {
         super(buffersize);
@@ -59,7 +57,7 @@
     public void reset(final HttpParams params) {
         this.charset = Charset.forName(HttpProtocolParams.getHttpElementCharset(params));

         this.chardecoder = this.charset.newDecoder();
-        this.maxLineLen = params.getIntParameter(HttpConnectionParams.MAX_LINE_LENGTH, -1);
+        clear();
     }
 
     public int fill(final ReadableByteChannel channel) throws IOException {
@@ -74,7 +72,7 @@
         return readNo;
     }
     
-    public int read(final byte[] b, int off, int len) throws IOException {
+    public int read(final byte[] b, int off, int len) {
         if (b == null) {
             return 0;
         };
@@ -87,7 +85,7 @@
         return chunk;
     }
     
-    public int read(final byte[] b) throws IOException {
+    public int read(final byte[] b) {
         if (b == null) {
             return 0;
         }
@@ -95,13 +93,12 @@
         return read(b, 0, b.length);
     }
     
-    public int read() throws IOException {
+    public int read() {
         setOutputMode();
         return this.buffer.get() & 0xff;
     }
     
-    public boolean readLine(final CharArrayBuffer linebuffer, boolean endOfStream) 
-            throws IOException {
+    public boolean readLine(final CharArrayBuffer linebuffer, boolean endOfStream) {
         setOutputMode();
         // See if there is LF char present in the buffer
         int pos = -1;
@@ -119,9 +116,6 @@
                 // No more data. Get the rest
                 pos = this.buffer.limit();
             } else {
-                if (this.maxLineLen > 0 && this.buffer.remaining() >= this.maxLineLen)
{
-                    throw new IOException("Maximum line length limit exceeded");
-                }
                 // Either no complete line present in the buffer 
                 // or no more data is expected
                 return false;

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionOutputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionOutputBuffer.java?view=diff&rev=466204&r1=466203&r2=466204
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionOutputBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/SessionOutputBuffer.java
Fri Oct 20 10:01:46 2006
@@ -30,6 +30,7 @@
 package org.apache.http.nio.impl;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.Charset;
@@ -59,6 +60,7 @@
     public void reset(final HttpParams params) {
         this.charset = Charset.forName(HttpProtocolParams.getHttpElementCharset(params));

         this.charencoder = this.charset.newEncoder();
+        clear();
     }
 
     public int flush(final WritableByteChannel channel) throws IOException {
@@ -70,7 +72,17 @@
         return noWritten;
     }
 
-    public void write(final byte[] b, int off, int len) throws IOException {
+    public void write(final ByteBuffer src) {
+        if (buffer == null) {
+            return;
+        }
+        setInputMode();
+        int requiredCapacity = src.remaining();
+        ensureCapacity(requiredCapacity);
+        this.buffer.put(src);
+    }
+
+    public void write(final byte[] b, int off, int len) {
         if (b == null) {
             return;
         }
@@ -80,14 +92,14 @@
         this.buffer.put(b, off, len);
     }
 
-    public void write(final byte[] b) throws IOException {
+    public void write(final byte[] b) {
         if (b == null) {
             return;
         }
         write(b, 0, b.length);
     }
 
-    private void writeCRLF() throws IOException {
+    private void writeCRLF() {
         write(CRLF);
     }
 
@@ -98,7 +110,7 @@
         this.buffer.put((byte)b);
     }
 
-    public void writeLine(final CharArrayBuffer linebuffer) throws IOException {
+    public void writeLine(final CharArrayBuffer linebuffer) {
         if (linebuffer == null) {
             return;
         }



Mime
View raw message