hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r227503 - in /jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote: ./ impl/ params/
Date Thu, 04 Aug 2005 21:52:36 GMT
Author: olegk
Date: Thu Aug  4 14:52:24 2005
New Revision: 227503

URL: http://svn.apache.org/viewcvs?rev=227503&view=rev
Log:
Change log:
* Added Tomcat Coyote specific impl of the HttpServerConnection interface based on DefaultHttpServerConnection
* Added HttpConnectionFactory interface and its default impl
* Added Tomcat Coyote specific HttpParam facade class
* Extended functionality of the CoyoteHttpService class

Added:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
  (with props)
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
  (with props)
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
  (with props)
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
  (with props)
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
  (with props)
Modified:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpService.java
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java?rev=227503&r1=227502&r2=227503&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java
Thu Aug  4 14:52:24 2005
@@ -38,8 +38,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpServerConnection;
-import org.apache.http.impl.DefaultHttpParams;
-import org.apache.http.impl.DefaultHttpServerConnection;
+import org.apache.http.coyote.params.CoyoteParams;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -55,17 +54,31 @@
 	
     private volatile boolean destroyed = false;
     
-    private final ServerSocketChannel serverchannel;
+    private final HttpConnectionFactory connfactory;
     private final HttpConnectionManager connmanager;
-    
-    public ConnectionListener(int port, final HttpConnectionManager connmanager) 
-            throws IOException {
+    private final HttpParams params;
+    private final ServerSocketChannel serverchannel;
+        
+    public ConnectionListener(
+            final HttpConnectionFactory connfactory,
+            final HttpConnectionManager connmanager,
+            final HttpParams params) throws IOException {
     	super();
+        if (connfactory == null) {
+            throw new IllegalArgumentException("Connection factory may not be null");
+        }
         if (connmanager == null) {
             throw new IllegalArgumentException("Connection manager may not be null");
         }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
         this.connmanager = connmanager;
+        this.connfactory = connfactory;
+        this.params = params;
         this.serverchannel = ServerSocketChannel.open();
+        
+        int port = CoyoteParams.getPort(this.params);
         this.serverchannel.socket().bind(new InetSocketAddress(port));
     }
 
@@ -78,12 +91,11 @@
                 try {
                     SocketChannel channel = this.serverchannel.accept();
                     Socket socket = channel.socket();
-                    HttpServerConnection conn = new DefaultHttpServerConnection();
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Incoming connection from " + socket.getRemoteSocketAddress());
                     }
-                    HttpParams defaparams = new DefaultHttpParams(); 
-                    conn.bind(socket, defaparams);
+                    HttpServerConnection conn = this.connfactory.newConnection(
+                            socket, this.params);
                     this.connmanager.process(conn);
                 } catch (Throwable ex) {
                     break;

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java?rev=227503&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
Thu Aug  4 14:52:24 2005
@@ -0,0 +1,50 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.coyote;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.http.HttpServerConnection;
+import org.apache.http.params.HttpParams;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public interface HttpConnectionFactory {
+
+    HttpServerConnection newConnection(Socket socket, HttpParams params)
+        throws IOException;
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java?rev=227503&r1=227502&r2=227503&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
Thu Aug  4 14:52:24 2005
@@ -40,7 +40,9 @@
 import org.apache.coyote.Adapter;
 import org.apache.coyote.ProtocolHandler;
 import org.apache.http.coyote.impl.CoyoteHttpService;
+import org.apache.http.coyote.impl.DefaultHttpConnectionFactory;
 import org.apache.http.coyote.impl.DefaultHttpConnectionManager;
+import org.apache.http.coyote.params.CoyoteParams;
 import org.apache.http.impl.DefaultHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
@@ -61,7 +63,6 @@
     private final HttpParams params;
 
 	private Adapter adapter = null;
-	private int port = 8080;
 	private int minThreads = 0;
 	private int maxThreads = 20;
     
@@ -77,11 +78,11 @@
 	}
 
 	public int getPort() {
-		return this.port;
+		return CoyoteParams.getPort(this.params);
 	}
 	
 	public void setPort(int port) {
-		this.port = port;
+        CoyoteParams.setPort(this.params, port);
 	}
 
 	public int getMinThreads() {
@@ -121,8 +122,9 @@
                 0L, TimeUnit.MILLISECONDS,
                 new LinkedBlockingQueue<Runnable>());
         this.listener = new ConnectionListener(
-                this.port, 
-                this.connmanager);
+                new DefaultHttpConnectionFactory(), 
+                this.connmanager,
+                this.params);
 	}
 
     public void destroy() throws Exception {

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java?rev=227503&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
Thu Aug  4 14:52:24 2005
@@ -0,0 +1,65 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.coyote;
+
+import org.apache.http.ProtocolException;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class MalformedURIException extends ProtocolException {
+
+    static final long serialVersionUID = 3231590809087677525L;
+	
+    /**
+     * Creates a MalformedURIException with a <tt>null</tt> detail message.
+     */
+    public MalformedURIException() {
+        super();
+    }
+
+    /**
+     * Creates a MalformedURIException with the specified detail message.
+     * 
+     * @param message The exception detail message 
+     */
+    public MalformedURIException(final String message) {
+        super(message);
+    }
+
+    public MalformedURIException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/MalformedURIException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java?rev=227503&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
Thu Aug  4 14:52:24 2005
@@ -0,0 +1,92 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.coyote.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.impl.DefaultHttpServerConnection;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class CoyoteHttpConnection extends DefaultHttpServerConnection {
+
+    private static Log LOG = LogFactory.getLog(CoyoteHttpConnection.class);
+    private static Log WIRE_LOG = LogFactory.getLog("coyote.wire");
+    
+    public CoyoteHttpConnection() {
+        super();
+    }
+
+    @Override
+    protected boolean isErrorEnabled() {
+        return LOG.isErrorEnabled();
+    }
+
+    @Override
+    protected void error(final String s, final Throwable t) {
+        LOG.error(s, t);
+    }
+
+    @Override
+    protected void error(final String s) {
+        LOG.error(s);
+    }
+
+    @Override
+    protected boolean isWarnEnabled() {
+        return LOG.isWarnEnabled();
+    }
+
+    @Override
+    protected void warn(final String s, final Throwable t) {
+        LOG.warn(s, t);
+    }
+
+    @Override
+    protected void warn(final String s) {
+        LOG.warn(s);
+    }
+
+    @Override
+    protected boolean isWirelogEnabled() {
+        return WIRE_LOG.isDebugEnabled();
+    }
+
+    @Override
+    protected void wirelog(String s) {
+        WIRE_LOG.debug(s);
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpService.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpService.java?rev=227503&r1=227502&r2=227503&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpService.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpService.java
Thu Aug  4 14:52:24 2005
@@ -34,7 +34,9 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.coyote.Adapter;
+import org.apache.coyote.Constants;
 import org.apache.coyote.Request;
+import org.apache.coyote.RequestInfo;
 import org.apache.coyote.Response;
 import org.apache.http.Header;
 import org.apache.http.HttpException;
@@ -44,6 +46,7 @@
 import org.apache.http.MethodNotSupportedException;
 import org.apache.http.ProtocolException;
 import org.apache.http.coyote.HttpService;
+import org.apache.http.impl.DefaultHttpParams;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -65,11 +68,9 @@
         if (adapter == null) {
             throw new IllegalArgumentException("Coyote adapter may not be null");
         }
-        if (params == null) {
-            throw new IllegalArgumentException("Http parameters may not be null");
-        }
         this.adapter = adapter;
-        this.params = params;
+        this.params = new DefaultHttpParams();
+        this.params.setDefaults(params);
     }
 
     public HttpParams getParams() {
@@ -92,9 +93,15 @@
     public void process(final HttpRequest httpreq, final HttpMutableResponse httpres) 
             throws IOException, HttpException {
         LOG.debug("Processing HTTP request");
-        Request request = CoyoteObjectFactory.newRequest(httpreq);
+        Request request = new Request();
+        request.setStartTime(System.currentTimeMillis());
+        RequestInfo reqinfo = request.getRequestProcessor();
+        reqinfo.setStage(Constants.STAGE_PARSE);
+        CoyoteObjectFactory.convert(httpreq, request);
+        reqinfo.setStage(Constants.STAGE_PREPARE);
         Response response = new Response();
         try {
+            reqinfo.setStage(Constants.STAGE_SERVICE);
             this.adapter.service(request, response);
         } catch (IOException ex) {
             throw ex;
@@ -102,5 +109,5 @@
             throw new HttpException(ex.getMessage(), ex.getCause()) ;
         }
 	}
-       
+    
 }

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java?rev=227503&r1=227502&r2=227503&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
Thu Aug  4 14:52:24 2005
@@ -29,15 +29,21 @@
 
 package org.apache.http.coyote.impl;
 
-import org.apache.coyote.Constants;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+
 import org.apache.coyote.Request;
-import org.apache.coyote.RequestInfo;
 import org.apache.http.Header;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
 import org.apache.http.RequestLine;
+import org.apache.http.coyote.MalformedURIException;
 import org.apache.http.coyote.UnsupportedHttpVersionException;
+import org.apache.http.coyote.params.CoyoteParams;
 
 /**
  * <p>
@@ -48,40 +54,83 @@
  */
 public class CoyoteObjectFactory {
 
-    public static Request newRequest(final HttpRequest httpreq) throws HttpException {
+    public static void convert(final HttpRequest httpreq, final Request coyotereq) 
+            throws HttpException {
         if (httpreq == null) {
             throw new IllegalArgumentException("HTTP request may not be null");
         }
-        Request coyotereq = new Request();
-        coyotereq.setStartTime(System.currentTimeMillis());
-        RequestInfo reqinfo = coyotereq.getRequestProcessor();
-        
-        reqinfo.setStage(Constants.STAGE_PARSE);
-        coyotereq.scheme().setString("http");
+        if (coyotereq == null) {
+            throw new IllegalArgumentException("Coyote request may not be null");
+        }
         RequestLine reqline = httpreq.getRequestLine();
+        HttpVersion ver = reqline.getHttpVersion();
+        if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
+            throw new UnsupportedHttpVersionException("Unsupported verion: " + ver); 
+        }
         coyotereq.method().setString(reqline.getMethod());
-        String fulluri = reqline.getUri();
-        coyotereq.unparsedURI().setString(fulluri);
-        int questionPos = fulluri.indexOf('?');
-        if (questionPos == -1) {
-            coyotereq.requestURI().setString(fulluri);
+        coyotereq.unparsedURI().setString(reqline.getUri());
+        
+        // Parse the request URI
+        URI uri = null;
+        try {
+            uri = new URI(reqline.getUri());
+        } catch (URISyntaxException ex) {
+            throw new MalformedURIException("Malformed URI: " + reqline.getUri(), ex);
+        }
+        if (uri.isAbsolute()) {
+            // Absolute request URI. Ignore the 'host' header 
+            coyotereq.scheme().setString(uri.getScheme());
+            coyotereq.serverName().setString(uri.getHost());
+            int port = uri.getPort();
+            if (port < 0) {
+            	port = 80;
+            }
+            coyotereq.setServerPort(port);
         } else {
-            coyotereq.requestURI().setString(fulluri.substring(0, questionPos));
-            coyotereq.queryString().setString(fulluri.substring(questionPos + 1));
+            // Relative request URI. Parse the 'host' header 
+            coyotereq.scheme().setString("http");
+            Header header = httpreq.getFirstHeader("host");
+            if (header != null) {
+                String s = header.getValue();
+                int i = s.lastIndexOf(':');
+                if (i != -1) {
+                    coyotereq.serverName().setString(s.substring(0, i));
+                    try {
+                        coyotereq.setServerPort(Integer.parseInt(s.substring(i + 1)));
+                    } catch (NumberFormatException ex) {
+                        throw new ProtocolException("Invalid target host: " + s); 
+                    }
+                } else {
+                    coyotereq.serverName().setString(s);
+                }
+            } else {
+                if (ver.greaterEquals(HttpVersion.HTTP_1_1)) {
+                    throw new ProtocolException("Target host not known"); 
+                }
+                // HTTP/1.0 compatibility
+                // User the default host and port values 
+                String defaulthost = null;
+                try {
+                    InetAddress localhost = InetAddress.getLocalHost();
+                    defaulthost = localhost.getHostName();
+                } catch (UnknownHostException ex) {
+                    defaulthost = "localhost";
+                }
+                coyotereq.setLocalHost(defaulthost);
+                coyotereq.serverName().setString(defaulthost);
+                coyotereq.setServerPort(CoyoteParams.getPort(httpreq.getParams()));
+            }
         }
-        coyotereq.protocol().setString(reqline.getHttpVersion().toString());
+        coyotereq.requestURI().setString(uri.getPath());
+        if (uri.getQuery() != null) {
+            coyotereq.queryString().setString(uri.getQuery());
+        }
+        coyotereq.protocol().setString(ver.toString());
+
         Header[] headers = httpreq.getAllHeaders();
         for (Header header: headers) {
-        	coyotereq.getMimeHeaders().addValue(header.getName()).setString(header.getValue());
+            coyotereq.getMimeHeaders().addValue(header.getName()).setString(header.getValue());
         }
-        
-        reqinfo.setStage(Constants.STAGE_PREPARE);
-        if (!reqline.getHttpVersion().lessEquals(HttpVersion.HTTP_1_1)) {
-        	throw new UnsupportedHttpVersionException("Unsupported verion: " + 
-        			reqline.getHttpVersion()); 
-        }
-        
-        return coyotereq;
     }
        
 }

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java?rev=227503&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
Thu Aug  4 14:52:24 2005
@@ -0,0 +1,59 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.coyote.impl;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.http.HttpServerConnection;
+import org.apache.http.coyote.HttpConnectionFactory;
+import org.apache.http.params.HttpParams;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class DefaultHttpConnectionFactory implements HttpConnectionFactory {
+
+    public DefaultHttpConnectionFactory() {
+        super();
+    }
+    
+    public HttpServerConnection newConnection(final Socket socket, final HttpParams params)
+            throws IOException {
+        HttpServerConnection conn = new CoyoteHttpConnection();
+        conn.bind(socket, params);
+        return conn;
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java?rev=227503&r1=227502&r2=227503&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Thu Aug  4 14:52:24 2005
@@ -44,8 +44,6 @@
 import org.apache.http.impl.BasicHttpResponse;
 import org.apache.http.impl.ConnectionReuseStrategy;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpParams;
-import org.apache.http.params.HttpParams;
 
 /**
  * <p>
@@ -63,7 +61,6 @@
     private final HttpServerConnection conn;
     private final HttpService service;
     private final IOProcessingListener listener;
-    private final HttpParams params;
     
     public HttpConnectionProcessor(
             final HttpServerConnection conn,
@@ -79,8 +76,6 @@
         this.conn = conn;
         this.service = service;
         this.listener = listener;
-        this.params = new DefaultHttpParams();
-        this.params.setDefaults(service.getParams());
     }
 
     public void run() {
@@ -110,7 +105,7 @@
     private void process() throws IOException {
         BasicHttpResponse response = new BasicHttpResponse();
         try {
-            HttpRequest request = this.conn.receiveRequest(this.params);
+            HttpRequest request = this.conn.receiveRequest(this.service.getParams());
             LOG.debug("HTTP request received");
             this.service.process(request, response);
         } catch (ConnectionClosedException ex) {

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java?rev=227503&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
Thu Aug  4 14:52:24 2005
@@ -0,0 +1,82 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.coyote.params;
+
+import org.apache.http.params.HttpParams;
+
+/**
+ * This class implements an adaptor around the {@link HttpParams} interface
+ * to simplify manipulation of the connector specific parameters.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ * 
+ * @version $Revision$
+ */
+public final class CoyoteParams {
+
+    /**
+     * Defines the port the connector listens on.
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     */
+    public static final String CONNECTOR_PORT = "http.connector.port"; 
+
+    /**
+     */
+    private CoyoteParams() {
+        super();
+    }
+
+    /**
+     * Returns the port the connector listens on. 
+     *
+     * @return port number
+     */
+    public static int getPort(final HttpParams params) { 
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        return params.getIntParameter(CONNECTOR_PORT, 8080);
+    }
+    
+    /**
+     * Assigns the port the connector will be listening on. 
+     *
+     * @param port the port number
+     */
+    public static void setPort(final HttpParams params, int port) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setIntParameter(CONNECTOR_PORT, port);
+    }
+
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message