On Sat, 2007-07-28 at 14:28 +0200, Marcus Herou wrote:
> Cool.
> 
> Then I guess I should extend the HttpUriRequest instead ?
> 
> Something like this perhaps ?
> public interface ParsedHttpRequest extends HttpUriRequest
> {
>    Map<String, String[]> getParameters();
>    String getParameter(String name);
> }
> 
> Hmmm... No not involving httpclient into something which should be more
> core... and httpclient sound bad for something which resides on the server
> :)

A utility class may also be an alternative. QueryStringParser?

> I think actually I will make a merge of httpclient's HttpUriRequest with the
> ParsedParameterRequest and put it in a package named something like
> org.apache.http.* somewhere.
> 
> Re:
> "How about moving socket initialization code from SocketHttp*Connection
> to DefaultHttp*Connection classes? Would that address the issue?"
> 
> Hmm well yes an extension which only binds the socket, why not. However the
> socket is private in the Socket* so "this.socket=socket" cannot be setup
> from an extended class... That's why I did'nt subclass the DefaultHttp*
> class in the first way. Any thoughts ?

How about subclassing SocketHttp*Connection instead of
DefaultHttp*Connection? See the patch attached


>  Looked at my code ?
> 

Yes, I did. I would prefer a solution which would not require a new
parameter, though.

Oleg

> Kindly
> 
> //Marcus
> 

Index: /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
===================================================================
--- /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java	(revision 560341)
+++ /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java	(working copy)
@@ -34,6 +34,7 @@
 import java.io.IOException;
 import java.net.Socket;
 
+import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -54,7 +55,20 @@
     public void bind(
             final Socket socket, 
             final HttpParams params) throws IOException {
+        if (socket == null) {
+            throw new IllegalArgumentException("Socket may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
         assertNotOpen();
+        socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
+        socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
+        
+        int linger = HttpConnectionParams.getLinger(params);
+        if (linger >= 0) {
+            socket.setSoLinger(linger > 0, linger);
+        }
         super.bind(socket, params);
     }
 
Index: /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
===================================================================
--- /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java	(revision 560341)
+++ /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java	(working copy)
@@ -34,6 +34,7 @@
 import java.io.IOException;
 import java.net.Socket;
 
+import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -52,7 +53,20 @@
     }
     
     public void bind(final Socket socket, final HttpParams params) throws IOException {
+        if (socket == null) {
+            throw new IllegalArgumentException("Socket may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
         assertNotOpen();
+        socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
+        socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
+        
+        int linger = HttpConnectionParams.getLinger(params);
+        if (linger >= 0) {
+            socket.setSoLinger(linger > 0, linger);
+        }
         super.bind(socket, params);
     }
 
Index: /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
===================================================================
--- /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java	(revision 560358)
+++ /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java	(working copy)
@@ -99,14 +99,6 @@
         if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");
         }
-        socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
-        socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
-        
-        int linger = HttpConnectionParams.getLinger(params);
-        if (linger >= 0) {
-            socket.setSoLinger(linger > 0, linger);
-        }
-
         this.socket = socket;
 
         int buffersize = HttpConnectionParams.getSocketBufferSize(params);
Index: /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
===================================================================
--- /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java	(revision 560358)
+++ /home/oleg/src/apache.org/jakarta/httpcomponents/httpcore/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java	(working copy)
@@ -97,14 +97,6 @@
         if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");
         }
-        socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
-        socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
-        
-        int linger = HttpConnectionParams.getLinger(params);
-        if (linger >= 0) {
-            socket.setSoLinger(linger > 0, linger);
-        }
-
         this.socket = socket;
         
         int buffersize = HttpConnectionParams.getSocketBufferSize(params);

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to