hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r233340 - in /jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl: ./ io/
Date Thu, 18 Aug 2005 18:01:58 GMT
Author: olegk
Date: Thu Aug 18 11:01:50 2005
New Revision: 233340

URL: http://svn.apache.org/viewcvs?rev=233340&view=rev
Log:
Added an option to switch oldIO and NIO HTTP data receivers / transmitters

Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/AbstractHttpConnection.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataReceiverFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataTransmitterFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataReceiver.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataTransmitter.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/AbstractHttpConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/AbstractHttpConnection.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/AbstractHttpConnection.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/AbstractHttpConnection.java
Thu Aug 18 11:01:50 2005
@@ -65,8 +65,6 @@
     
     protected AbstractHttpConnection() {
         super();
-        this.trxfactory = new DefaultHttpDataTransmitterFactory();
-        this.rcvfactory = new DefaultHttpDataReceiverFactory();
     }
     
     public void setReceiverFactory(final HttpDataReceiverFactory rcvfactory) {
@@ -119,6 +117,12 @@
         int rcvBufSize = HttpConnectionParams.getReceiveBufferSize(params);
         if (rcvBufSize >= 0) {
             this.socket.setReceiveBufferSize(rcvBufSize);
+        }
+        if (this.trxfactory == null) {
+            this.trxfactory = new DefaultHttpDataTransmitterFactory();
+        }
+        if (this.rcvfactory == null) {
+            this.rcvfactory = new DefaultHttpDataReceiverFactory();
         }
         this.datatransmitter = this.trxfactory.create(this.socket); 
         this.datareceiver = this.rcvfactory.create(this.socket); 

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataReceiverFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataReceiverFactory.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataReceiverFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataReceiverFactory.java
Thu Aug 18 11:01:50 2005
@@ -49,18 +49,29 @@
  */
 public class DefaultHttpDataReceiverFactory implements HttpDataReceiverFactory {
     
+    private boolean useNIO;
+    
+    public DefaultHttpDataReceiverFactory(boolean useNIO) {
+        super();
+        this.useNIO = useNIO;
+    }
+    
+    public DefaultHttpDataReceiverFactory() {
+        this(true);
+    }
+
     public HttpDataReceiver create(final Socket socket) throws IOException {
         if (socket == null) {
             throw new IllegalArgumentException("Socket may not be null");
         }
         if (socket instanceof SSLSocket) {
-            if (HttpRuntime.isSSLNIOCapable()) {
+            if (this.useNIO && HttpRuntime.isSSLNIOCapable()) {
                 return new NIOSocketHttpDataReceiver(socket); 
             } else {
                 return new OldIOSocketHttpDataReceiver(socket); 
             }
         } else {
-            if (HttpRuntime.isNIOCapable()) {
+            if (this.useNIO && HttpRuntime.isNIOCapable()) {
                 return new NIOSocketHttpDataReceiver(socket); 
             } else {
                 return new OldIOSocketHttpDataReceiver(socket); 

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataTransmitterFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataTransmitterFactory.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataTransmitterFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/DefaultHttpDataTransmitterFactory.java
Thu Aug 18 11:01:50 2005
@@ -49,18 +49,29 @@
  */
 public class DefaultHttpDataTransmitterFactory implements HttpDataTransmitterFactory {
     
+    private boolean useNIO;
+    
+    public DefaultHttpDataTransmitterFactory(boolean useNIO) {
+        super();
+        this.useNIO = useNIO;
+    }
+    
+    public DefaultHttpDataTransmitterFactory() {
+        this(true);
+    }
+
     public HttpDataTransmitter create(final Socket socket) throws IOException {
         if (socket == null) {
             throw new IllegalArgumentException("Socket may not be null");
         }
         if (socket instanceof SSLSocket) {
-            if (HttpRuntime.isSSLNIOCapable()) {
+            if (this.useNIO && HttpRuntime.isSSLNIOCapable()) {
                 return new NIOSocketHttpDataTransmitter(socket); 
             } else {
                 return new OldIOSocketHttpDataTransmitter(socket); 
             }
         } else {
-            if (HttpRuntime.isNIOCapable()) {
+            if (this.useNIO && HttpRuntime.isNIOCapable()) {
                 return new NIOSocketHttpDataTransmitter(socket); 
             } else {
                 return new OldIOSocketHttpDataTransmitter(socket); 

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataReceiver.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataReceiver.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataReceiver.java
Thu Aug 18 11:01:50 2005
@@ -60,7 +60,7 @@
     private Charset charset = null;
     
     protected void initBuffer(int buffersize) {
-        if ((buffersize < 2048)) {
+        if (buffersize < 2048) {
             buffersize = 2048;
         }
         this.buffer = ByteBuffer.allocateDirect(buffersize);

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataTransmitter.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataTransmitter.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/NIOHttpDataTransmitter.java
Thu Aug 18 11:01:50 2005
@@ -61,7 +61,7 @@
     private Charset charset = null;
 
     protected void initBuffer(int buffersize) {
-        if ((buffersize < 2048)) {
+        if (buffersize < 2048) {
             buffersize = 2048;
         }
         this.buffer = ByteBuffer.allocateDirect(buffersize);

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
Thu Aug 18 11:01:50 2005
@@ -79,7 +79,7 @@
             throw new IllegalArgumentException("Socket may not be null");
         }
         int buffersize = socket.getReceiveBufferSize();
-        if ((buffersize > 2048) || (buffersize <= 0)) {
+        if (buffersize < 2048) {
             buffersize = 2048;
         }
         return new BufferedInputStream(socket.getInputStream(), buffersize);

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java?rev=233340&r1=233339&r2=233340&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
Thu Aug 18 11:01:50 2005
@@ -52,7 +52,7 @@
             throw new IllegalArgumentException("Socket may not be null");
         }
         int buffersize = socket.getSendBufferSize();
-        if ((buffersize > 2048) || (buffersize <= 0)) {
+        if (buffersize < 2048) {
             buffersize = 2048;
         }
         return new BufferedOutputStream(socket.getOutputStream(), buffersize);



Mime
View raw message