hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r161607 - in jakarta/httpclient/trunk/http-common/src: java/org/apache/http/ java/org/apache/http/impl/ test/org/apache/http/impl/
Date Sat, 16 Apr 2005 21:18:43 GMT
Author: olegk
Date: Sat Apr 16 14:18:39 2005
New Revision: 161607

URL: http://svn.apache.org/viewcvs?view=rev&rev=161607
Log:
Initial import of the default HttpServerConnection impl. (It has not been tested and most likely is not functional)

Added:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingRequest.java
      - copied, changed from r160526, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingMessage.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java   (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpEntityEnclosingRequest.java   (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpServerConnection.java   (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpRequestFactory.java   (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpResponseFactory.java   (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/MethodNotSupportedException.java   (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/RequestValidationException.java   (with props)
Removed:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingMessage.java
Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableRequest.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableResponse.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpOutgoingEntity.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpRequest.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpResponse.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestBasicRequest.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultResponseConsumedWatcher.java

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingRequest.java (from r160526, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingMessage.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingRequest.java?view=diff&rev=161607&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingMessage.java&r1=160526&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingRequest.java&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingMessage.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpEntityEnclosingRequest.java Sat Apr 16 14:18:39 2005
@@ -38,10 +38,8 @@
  * 
  * @since 4.0
  */
-public interface HttpEntityEnclosingMessage extends HttpMessage {
+public interface HttpEntityEnclosingRequest extends HttpRequest {
 
-    void setEntity(HttpOutgoingEntity entity);
-    
-    HttpOutgoingEntity getEntity();
+    HttpEntity getEntity();
     
 }

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java Sat Apr 16 14:18:39 2005
@@ -0,0 +1,45 @@
+/*
+ * $Header: $
+ * $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;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface HttpMutableEntityEnclosingRequest extends HttpEntityEnclosingRequest {
+
+    void setEntity(HttpEntity entity);
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableEntityEnclosingRequest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableRequest.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableRequest.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableRequest.java Sat Apr 16 14:18:39 2005
@@ -40,6 +40,4 @@
  */
 public interface HttpMutableRequest extends HttpRequest, HttpMutableMessage {
 
-    void setRequestLine(RequestLine requestline);
-    
 }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableResponse.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableResponse.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableResponse.java Sat Apr 16 14:18:39 2005
@@ -40,8 +40,6 @@
  */
 public interface HttpMutableResponse extends HttpMutableMessage, HttpResponse {
 
-    void setStatusLine(StatusLine statusline);
-
     void setEntity(HttpEntity entity);
     
 }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpOutgoingEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpOutgoingEntity.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpOutgoingEntity.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpOutgoingEntity.java Sat Apr 16 14:18:39 2005
@@ -30,8 +30,7 @@
 package org.apache.http;
 
 import java.io.IOException;
-
-import org.apache.http.io.HttpDataTransmitter;
+import java.io.OutputStream;
 
 /**
  * <p>
@@ -44,6 +43,6 @@
  */
 public interface HttpOutgoingEntity extends HttpEntity {
 
-    void writeTo(HttpDataTransmitter datatransmitter) throws IOException;
+    void writeTo(OutputStream outstream) throws IOException;
     
 }

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpEntityEnclosingRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpEntityEnclosingRequest.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpEntityEnclosingRequest.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpEntityEnclosingRequest.java Sat Apr 16 14:18:39 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.impl;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpMutableEntityEnclosingRequest;
+import org.apache.http.RequestLine;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class BasicHttpEntityEnclosingRequest 
+            extends BasicHttpRequest implements HttpMutableEntityEnclosingRequest {
+    
+    private HttpEntity entity = null;
+    
+    protected BasicHttpEntityEnclosingRequest(final String method, final String uri) {
+        super(method, uri);
+    }
+
+    protected BasicHttpEntityEnclosingRequest(final RequestLine requestline) {
+        super(requestline);
+    }
+
+    public HttpEntity getEntity() {
+        return this.entity;
+    }
+
+    public void setEntity(final HttpEntity entity) {
+        this.entity = entity;
+    }
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpEntityEnclosingRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpRequest.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpRequest.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpRequest.java Sat Apr 16 14:18:39 2005
@@ -45,10 +45,10 @@
  */
 public class BasicHttpRequest extends BasicHttpMessage implements HttpMutableRequest {
     
-    private String method = null;
-    private String uri = null;
-    private RequestLine requestline = null;
-    
+    private final RequestLine requestline;
+    private final String method;
+    private final String uri;
+        
     protected BasicHttpRequest(final String method, final String uri) {
         super();
         if (method == null) {
@@ -59,11 +59,17 @@
         }
         this.method = method;
         this.uri = uri;
+        this.requestline = null;
     }
 
     protected BasicHttpRequest(final RequestLine requestline) {
         super();
-        setRequestLine(requestline);
+        if (requestline == null) {
+            throw new IllegalArgumentException("Request line may not be null");
+        }
+        this.requestline = requestline;
+        this.method = requestline.getMethod();
+        this.uri = requestline.getUri();
     }
 
     public RequestLine getRequestLine() {
@@ -74,14 +80,4 @@
             return new RequestLine(this.method, this.uri, ver);
         }
     }
-
-    public void setRequestLine(final RequestLine requestline) {
-        if (requestline == null) {
-            throw new IllegalArgumentException("Request line may not be null");
-        }
-        this.requestline = requestline;
-        this.method = requestline.getMethod();
-        this.uri = requestline.getUri();
-    }
-    
 }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpResponse.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpResponse.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpResponse.java Sat Apr 16 14:18:39 2005
@@ -47,26 +47,18 @@
     private StatusLine statusline = null;
     private HttpEntity entity = null;
     
-    public BasicHttpResponse() {
-        super();
-    }
-
     public BasicHttpResponse(final StatusLine statusline) {
         super();
-        setStatusLine(statusline);
+        if (statusline == null) {
+            throw new IllegalArgumentException("Status line may not be null");
+        }
+        this.statusline = statusline;
     }
 
     public StatusLine getStatusLine() {
         return this.statusline; 
     }
 
-    public void setStatusLine(final StatusLine statusline) {
-        if (statusline == null) {
-            throw new IllegalArgumentException("Status line may not be null");
-        }
-        this.statusline = statusline;
-    }
-    
     public HttpEntity getEntity() {
         return this.entity;
     }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java Sat Apr 16 14:18:39 2005
@@ -31,12 +31,13 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.InetAddress;
 import java.net.Socket;
 
 import org.apache.http.Header;
 import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpEntityEnclosingMessage;
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpMutableEntity;
@@ -50,6 +51,8 @@
 import org.apache.http.ProtocolException;
 import org.apache.http.ProtocolSocketFactory;
 import org.apache.http.StatusLine;
+import org.apache.http.io.ChunkedOutputStream;
+import org.apache.http.io.HttpDataOutputStream;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.util.HeadersParser;
@@ -116,13 +119,16 @@
         sendRequestLine(request);
         sendRequestHeaders(request);
         
-        HttpResponse response = null;
-        if (request instanceof HttpEntityEnclosingMessage) {
+        if (request instanceof HttpEntityEnclosingRequest) {
             // send request may be prematurely terminated by the target server
-            response = sendRequestBody(request);
+            HttpResponse response = expectContinue(request);
+            if (response != null) {
+                return response;
+            }
+            sendRequestBody((HttpEntityEnclosingRequest)request);
         }
         this.datatransmitter.flush();
-        return response;
+        return null;
     }
     
     protected void sendRequestLine(
@@ -150,14 +156,11 @@
         }
     }
 
-    protected HttpResponse sendRequestBody(final HttpRequest request) 
-                                                    throws HttpException, IOException {
-        HttpOutgoingEntity entity = ((HttpEntityEnclosingMessage)request).getEntity();
-        if (entity == null) {
-            return null;
-        }
-        // See if 'expect-continue' handshake is supported 
-        if (HttpVersion.HTTP_1_1.greaterEquals(request.getRequestLine().getHttpVersion())) {
+    protected HttpResponse expectContinue(final HttpRequest request) 
+            throws HttpException, IOException {
+        // See if 'expect-continue' handshake is supported
+        HttpVersion ver = request.getRequestLine().getHttpVersion();
+        if (ver.greaterEquals(HttpVersion.HTTP_1_1)) {
             // ... and activated
             Header expect = request.getFirstHeader(EXPECT_DIRECTIVE);
             if (expect != null && EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue())) {
@@ -177,10 +180,31 @@
                 }
             }
         }
-        entity.writeTo(this.datatransmitter);
         return null;
     }
     
+    protected void sendRequestBody(final HttpEntityEnclosingRequest request) 
+            throws HttpException, IOException {
+        if (request.getEntity() == null) {
+            return;
+        }
+        HttpOutgoingEntity entity = (HttpOutgoingEntity)request.getEntity();
+        HttpVersion ver = request.getRequestLine().getHttpVersion();
+        if (entity.isChunked() && ver.lessEquals(HttpVersion.HTTP_1_0)) {
+            throw new ProtocolException(
+                    "Chunked transfer encoding not allowed for " + ver);
+        }
+        OutputStream outstream = new HttpDataOutputStream(this.datatransmitter);
+        if (entity.isChunked()) {
+            outstream = new ChunkedOutputStream(outstream);
+        }
+        entity.writeTo(outstream);
+        if (outstream instanceof ChunkedOutputStream) {
+            ((ChunkedOutputStream) outstream).finish();
+        }
+        outstream.flush();
+    }
+    
     public HttpResponse receiveResponse(final HttpRequest request) 
                                                     throws HttpException, IOException {
         if (request == null) {
@@ -192,19 +216,16 @@
         // reset the data receiver
         this.datareceiver.reset(params);
 
-        BasicHttpResponse response = new BasicHttpResponse();
-        response.setParams((HttpParams)params.clone());
-        
-        processResponseStatusLine(response);
+        HttpMutableResponse response = processResponseStatusLine(params);
         processResponseHeaders(response);
         processResponseBody(response);
         return response;
     }
     
-    protected void processResponseStatusLine(
-            final HttpMutableResponse response) throws HttpException, IOException {
+    protected HttpMutableResponse processResponseStatusLine(final HttpParams params) 
+                throws HttpException, IOException {
         //read out the HTTP status string
-        int maxGarbageLines = response.getParams().getIntParameter(
+        int maxGarbageLines = params.getIntParameter(
                 HttpProtocolParams.STATUS_LINE_GARBAGE_LIMIT, Integer.MAX_VALUE);
         int count = 0;
         String s;
@@ -229,10 +250,11 @@
             }
         } while(true);
         //create the status line from the status string
-        response.setStatusLine(StatusLine.parse(s));
+        StatusLine statusline = StatusLine.parse(s);
         if (isWirelogEnabled()) {
             wirelog("<< " + s + "[\\r][\\n]");
         }
+        return HttpResponseFactory.newHttpResponse(statusline);
     }
 
     protected void processResponseHeaders(

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpServerConnection.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpServerConnection.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpServerConnection.java Sat Apr 16 14:18:39 2005
@@ -0,0 +1,223 @@
+/*
+ * $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.impl;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import org.apache.http.Header;
+import org.apache.http.HttpException;
+import org.apache.http.HttpMutableEntity;
+import org.apache.http.HttpMutableEntityEnclosingRequest;
+import org.apache.http.HttpMutableRequest;
+import org.apache.http.HttpMutableResponse;
+import org.apache.http.HttpOutgoingEntity;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpServerConnection;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
+import org.apache.http.RequestLine;
+import org.apache.http.io.ChunkedOutputStream;
+import org.apache.http.io.HttpDataOutputStream;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.HeadersParser;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class DefaultHttpServerConnection 
+        extends AbstractHttpConnection implements HttpServerConnection {
+
+    private static final String EXPECT_DIRECTIVE = "Expect";
+    private static final String EXPECT_CONTINUE = "100-Continue";
+
+    public DefaultHttpServerConnection() {
+        super();
+    }
+    
+    public void bind(final Socket socket, final HttpParams params) throws IOException {
+        super.bind(socket, params);
+    }
+
+    public HttpRequest receiveRequest(final HttpParams params) 
+            throws HttpException, IOException {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        assertOpen();
+        // reset the data transmitter
+        this.datareceiver.reset(params);
+
+        HttpMutableRequest request = receiveRequestLine(params);
+        receiveRequestHeaders(request);
+
+        HttpVersion responsever = request.getRequestLine().getHttpVersion();
+        if (responsever.greaterEquals(HttpVersion.HTTP_1_1)) {
+            responsever = HttpVersion.HTTP_1_1;
+        }
+
+        boolean validated = false;
+        if (request instanceof HttpMutableEntityEnclosingRequest) {
+            if (expectContinue(request)) {
+                validateRequest(request);
+                validated = true;
+                sendContinue(responsever);
+                receiveRequestBody((HttpMutableEntityEnclosingRequest)request);
+            }
+        }
+        if (!validated) {
+            validateRequest(request);
+        }
+        return request;
+    }
+    
+    protected HttpMutableRequest receiveRequestLine(final HttpParams params)
+            throws HttpException, IOException {
+        String line = this.datareceiver.readLine();
+        if (line == null) {
+            throw new ProtocolException("Request line not found"); 
+        }
+        RequestLine requestline = RequestLine.parse(line);
+        if (isWirelogEnabled()) {
+            wirelog(">> " + line + "[\\r][\\n]");
+        }
+        HttpMutableRequest request = HttpRequestFactory.newHttpRequest(requestline);
+        request.setParams((HttpParams)params.clone());
+        return request;
+    }
+    
+    protected void receiveRequestHeaders(final HttpMutableRequest request) 
+            throws HttpException, IOException {
+        Header[] headers = HeadersParser.processHeaders(this.datareceiver);
+        for (int i = 0; i < headers.length; i++) {
+            request.addHeader(headers[i]);
+            if (isWirelogEnabled()) {
+                wirelog(">> " + headers[i].toString() + "[\\r][\\n]");
+            }
+        }
+        wirelog(">> [\\r][\\n]");
+    }
+
+    protected boolean expectContinue(final HttpRequest request) {
+        Header expect = request.getFirstHeader(EXPECT_DIRECTIVE);
+        return expect != null && EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
+    }
+
+    protected void validateRequest(final HttpRequest request)
+            throws RequestValidationException {
+    }
+    
+    protected void sendContinue(final HttpVersion ver) 
+            throws IOException, HttpException {
+        HttpMutableResponse response = 
+            HttpResponseFactory.newHttpResponse(ver, HttpStatus.SC_CONTINUE);
+        sendResponse(response);
+    }
+
+    protected void receiveRequestBody(final HttpMutableEntityEnclosingRequest request)
+            throws HttpException, IOException {
+        EntityGenerator entitygen = new DefaultEntityGenerator();
+        HttpMutableEntity entity = entitygen.generate(this.datareceiver, request);
+        request.setEntity(entity);
+    }
+    
+    
+    public void sendResponse(final HttpResponse response) 
+            throws HttpException, IOException {
+        if (response == null) {
+            throw new IllegalArgumentException("HTTP response may not be null");
+        }
+        assertOpen();
+
+        // reset the data transmitter
+        this.datatransmitter.reset(response.getParams());
+        sendResponseStatusLine(response);
+        sendResponseHeaders(response);
+        sendResponseBody(response);
+        this.datatransmitter.flush();
+    }
+    
+    protected void sendResponseStatusLine(final HttpResponse response) 
+            throws HttpException, IOException {
+        String line = response.getStatusLine().toString();
+        this.datatransmitter.writeLine(line);
+        if (isWirelogEnabled()) {
+            wirelog(">> " + line + "[\\r][\\n]");
+        }
+    }
+
+    protected void sendResponseHeaders(final HttpResponse response) 
+            throws HttpException, IOException {
+        Header[] headers = response.getAllHeaders();
+        for (int i = 0; i < headers.length; i++) {
+            String line = headers[i].toString();
+            this.datatransmitter.writeLine(line);
+            if (isWirelogEnabled()) {
+                wirelog(">> " + line + "[\\r][\\n]");
+            }
+        }
+        this.datatransmitter.writeLine("");
+        if (isWirelogEnabled()) {
+            wirelog(">> [\\r][\\n]");
+        }
+    }
+
+    protected void sendResponseBody(final HttpResponse response) 
+            throws HttpException, IOException {
+        if (response.getEntity() == null) {
+            return;
+        }
+        HttpOutgoingEntity entity = (HttpOutgoingEntity)response.getEntity();
+        HttpVersion ver = response.getStatusLine().getHttpVersion();
+        if (entity.isChunked() && ver.lessEquals(HttpVersion.HTTP_1_0)) {
+            throw new ProtocolException(
+                    "Chunked transfer encoding not allowed for " + ver);
+        }
+        OutputStream outstream = new HttpDataOutputStream(this.datatransmitter);
+        if (entity.isChunked()) {
+            outstream = new ChunkedOutputStream(outstream);
+        }
+        entity.writeTo(outstream);
+        if (outstream instanceof ChunkedOutputStream) {
+            ((ChunkedOutputStream) outstream).finish();
+        }
+        outstream.flush();
+    }  
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpRequestFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpRequestFactory.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpRequestFactory.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpRequestFactory.java Sat Apr 16 14:18:39 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.impl;
+
+import org.apache.http.HttpMutableRequest;
+import org.apache.http.RequestLine;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class HttpRequestFactory {
+    
+    private HttpRequestFactory() {
+        super();
+    }
+
+    public static HttpMutableRequest newHttpRequest(final RequestLine requestline)
+            throws MethodNotSupportedException {
+        if (requestline == null) {
+            throw new IllegalArgumentException("Request line may not be null");
+        }
+        String method = requestline.getMethod();
+        if ("GET".equalsIgnoreCase(method)) {
+            return new BasicHttpRequest(requestline); 
+        } else if ("POST".equalsIgnoreCase(method)) {
+            return new BasicHttpEntityEnclosingRequest(requestline); 
+        } else { 
+            throw new MethodNotSupportedException(method +  " method not supported");
+        }
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpRequestFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpResponseFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpResponseFactory.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpResponseFactory.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpResponseFactory.java Sat Apr 16 14:18:39 2005
@@ -0,0 +1,68 @@
+/*
+ * $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.impl;
+
+import org.apache.http.HttpMutableResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.StatusLine;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class HttpResponseFactory {
+    
+    private HttpResponseFactory() {
+        super();
+    }
+
+    public static HttpMutableResponse newHttpResponse(final HttpVersion ver, final int status)
+            throws MethodNotSupportedException {
+        if (ver == null) {
+            throw new IllegalArgumentException("HTTP version may not be null");
+        }
+        StatusLine statusline = new StatusLine(ver, status, HttpStatus.getStatusText(status)); 
+        return new BasicHttpResponse(statusline); 
+    }
+    
+    public static HttpMutableResponse newHttpResponse(final StatusLine statusline)
+            throws MethodNotSupportedException {
+        if (statusline == null) {
+            throw new IllegalArgumentException("Status line may not be null");
+        }
+        return new BasicHttpResponse(statusline); 
+    }
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/HttpResponseFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/MethodNotSupportedException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/MethodNotSupportedException.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/MethodNotSupportedException.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/MethodNotSupportedException.java Sat Apr 16 14:18:39 2005
@@ -0,0 +1,64 @@
+/*
+ * $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.impl;
+
+import org.apache.http.HttpException;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class MethodNotSupportedException extends HttpException {
+
+    /**
+     * Creates a new MethodNotSupportedException with the specified detail message.
+     * 
+     * @param message The exception detail message
+     */
+    public MethodNotSupportedException(final String message) {
+        super(message);
+    }
+
+    /**
+     * Creates a new MethodNotSupportedException with the specified detail message and cause.
+     * 
+     * @param message the exception detail message
+     * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
+     * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
+     */
+    public MethodNotSupportedException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/MethodNotSupportedException.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/RequestValidationException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/RequestValidationException.java?view=auto&rev=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/RequestValidationException.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/RequestValidationException.java Sat Apr 16 14:18:39 2005
@@ -0,0 +1,54 @@
+/*
+ * $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.impl;
+
+import org.apache.http.HttpException;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class RequestValidationException extends HttpException {
+
+    /**
+     * Creates a new RequestValidationException with the specified detail message.
+     * 
+     * @param message The exception detail message
+     */
+    public RequestValidationException(final String message) {
+        super(message);
+    }
+
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/RequestValidationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestBasicRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestBasicRequest.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestBasicRequest.java (original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestBasicRequest.java Sat Apr 16 14:18:39 2005
@@ -32,7 +32,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.http.HttpMutableRequest;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpVersion;
 import org.apache.http.RequestLine;
@@ -88,16 +87,6 @@
         assertEquals("GET", request.getRequestLine().getMethod());
         assertEquals("/stuff", request.getRequestLine().getUri());
         assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getHttpVersion());
-    }
-
-    public void testNullRequestLine() throws Exception {
-        HttpMutableRequest request = new BasicHttpRequest("GET", "/stuff");
-        try {
-            request.setRequestLine(null);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
     }
 
 }

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java (original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java Sat Apr 16 14:18:39 2005
@@ -70,8 +70,8 @@
         HttpMutableEntity entity = new BasicHttpEntity();
         entity.setChunked(false);
         entity.setContentLength(-1);
-        HttpMutableResponse response = new BasicHttpResponse();
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.setEntity(entity);
 
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
@@ -82,9 +82,9 @@
         HttpMutableEntity entity = new BasicHttpEntity();
         entity.setChunked(true);
         entity.setContentLength(-1);
-        HttpMutableResponse response = new BasicHttpResponse();
         // Use HTTP 1.1
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, 200, "OK");
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.addHeader(new Header("Connection", "close"));
         response.setEntity(entity);
 
@@ -96,9 +96,9 @@
         HttpMutableEntity entity = new BasicHttpEntity();
         entity.setChunked(false);
         entity.setContentLength(10);
-        HttpMutableResponse response = new BasicHttpResponse();
         // Use HTTP 1.0
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"); 
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.addHeader(new Header("Connection", "keep-alive"));
         response.setEntity(entity);
 
@@ -107,33 +107,33 @@
     }
 
     public void testHTTP10Default() throws Exception {
-        HttpMutableResponse response = new BasicHttpResponse();
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"); 
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
 
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
         assertFalse(s.keepAlive(response));
     }
     
     public void testHTTP11Default() throws Exception {
-        HttpMutableResponse response = new BasicHttpResponse();
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, 200, "OK"); 
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
 
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
         assertTrue(s.keepAlive(response));
     }
 
     public void testFutureHTTP() throws Exception {
-        HttpMutableResponse response = new BasicHttpResponse();
-        response.setStatusLine(new StatusLine(new HttpVersion(3, 45), 200, "OK"));
+        StatusLine statusline = new StatusLine(new HttpVersion(3, 45), 200, "OK"); 
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
 
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
         assertTrue(s.keepAlive(response));
     }
     
     public void testBrokenConnectionDirective1() throws Exception {
-        HttpMutableResponse response = new BasicHttpResponse();
         // Use HTTP 1.0
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"); 
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.addHeader(new Header("Connection", "keep--alive"));
 
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
@@ -141,9 +141,9 @@
     }
 
     public void testBrokenConnectionDirective2() throws Exception {
-        HttpMutableResponse response = new BasicHttpResponse();
         // Use HTTP 1.0
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"); 
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.addHeader(new Header("Connection", null));
 
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultResponseConsumedWatcher.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultResponseConsumedWatcher.java?view=diff&r1=161606&r2=161607
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultResponseConsumedWatcher.java (original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestDefaultResponseConsumedWatcher.java Sat Apr 16 14:18:39 2005
@@ -84,8 +84,8 @@
         entity.setContentLength(data.length);
         entity.setInputStream(new ByteArrayInputStream(data));
         
-        HttpMutableResponse response = new BasicHttpResponse();
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_0, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.setHeader(new Header("Connection", "Close"));
         response.setParams(new DefaultHttpParams(null));
         response.setEntity(entity);
@@ -108,8 +108,8 @@
         entity.setContentLength(data.length);
         entity.setInputStream(new ByteArrayInputStream(data));
         
-        HttpMutableResponse response = new BasicHttpResponse();
-        response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
+        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, 200, "OK");
+        HttpMutableResponse response = new BasicHttpResponse(statusline);
         response.setHeader(new Header("Connection", "Keep-alive"));
         response.setParams(new DefaultHttpParams(null));
         response.setEntity(entity);



Mime
View raw message