hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r227089 - in /jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote: UnsupportedHttpVersionException.java impl/CoyoteHttpService.java impl/CoyoteObjectFactory.java
Date Tue, 02 Aug 2005 21:55:33 GMT
Author: olegk
Date: Tue Aug  2 14:55:28 2005
New Revision: 227089

URL: http://svn.apache.org/viewcvs?rev=227089&view=rev
Log:
Added an object factory intended to convert HTTP requests/response objects to corresponding
Coyote requests/response objects

Added:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/UnsupportedHttpVersionException.java
  (with props)
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
  (with props)
Modified:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpService.java

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/UnsupportedHttpVersionException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/UnsupportedHttpVersionException.java?rev=227089&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/UnsupportedHttpVersionException.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/UnsupportedHttpVersionException.java
Tue Aug  2 14:55:28 2005
@@ -0,0 +1,61 @@
+/*
+ * $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 UnsupportedHttpVersionException extends ProtocolException {
+
+	static final long serialVersionUID = 6838964812421632743L;
+	
+    /**
+     * Creates a NotImplementedException with a <tt>null</tt> detail message.
+     */
+    public UnsupportedHttpVersionException() {
+        super();
+    }
+
+    /**
+     * Creates a NotImplementedException with the specified detail message.
+     * 
+     * @param message The exception detail message 
+     */
+    public UnsupportedHttpVersionException(final String message) {
+        super(message);
+    }
+
+}

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

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

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/UnsupportedHttpVersionException.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=227089&r1=227088&r2=227089&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
Tue Aug  2 14:55:28 2005
@@ -34,9 +34,7 @@
 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;
@@ -94,13 +92,7 @@
     public void process(final HttpRequest httpreq, final HttpMutableResponse httpres) 
             throws IOException, HttpException {
         LOG.debug("Processing HTTP request");
-        Request request = new Request();
-        request.setStartTime(System.currentTimeMillis());
-        
-        RequestInfo reqinfo = request.getRequestProcessor();
-        reqinfo.setStage(Constants.STAGE_PARSE);
-        // convertRequest(httpreq, request);
-
+        Request request = CoyoteObjectFactory.newRequest(httpreq);
         Response response = new Response();
         try {
             this.adapter.service(request, response);

Added: 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=227089&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteObjectFactory.java
Tue Aug  2 14:55:28 2005
@@ -0,0 +1,87 @@
+/*
+ * $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.coyote.Constants;
+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.RequestLine;
+import org.apache.http.coyote.UnsupportedHttpVersionException;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class CoyoteObjectFactory {
+
+    public static Request newRequest(final HttpRequest httpreq) 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");
+        RequestLine reqline = httpreq.getRequestLine();
+        coyotereq.method().setString(reqline.getMethod());
+        String fulluri = reqline.getUri();
+        coyotereq.unparsedURI().setString(fulluri);
+        int questionPos = fulluri.indexOf('?');
+        if (questionPos == -1) {
+            coyotereq.requestURI().setString(fulluri);
+        } else {
+            coyotereq.requestURI().setString(fulluri.substring(0, questionPos));
+            coyotereq.queryString().setString(fulluri.substring(questionPos + 1));
+        }
+        coyotereq.protocol().setString(reqline.getHttpVersion().toString());
+        Header[] headers = httpreq.getAllHeaders();
+        for (Header header: headers) {
+        	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;
+    }
+       
+}

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

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

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



Mime
View raw message