hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r357518 - in /jakarta/httpcomponents/trunk/http-core/src: examples/org/apache/http/examples/ java/org/apache/http/ java/org/apache/http/executor/ java/org/apache/http/impl/
Date Sun, 18 Dec 2005 22:08:12 GMT
Author: olegk
Date: Sun Dec 18 14:08:00 2005
New Revision: 357518

URL: http://svn.apache.org/viewcvs?rev=357518&view=rev
Log:
Changed HttpClientConnection interface

Modified:
    jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpGet.java
    jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpClientConnection.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/executor/HttpRequestExecutor.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java

Modified: jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpGet.java?rev=357518&r1=357517&r2=357518&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpGet.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpGet.java
Sun Dec 18 14:08:00 2005
@@ -79,7 +79,7 @@
                 }
                 System.out.println(">> Request URI: " + request.getRequestLine().getUri());
                 conn.sendRequest(request);
-                HttpResponse response = conn.receiveResponse(request.getParams()); 
+                HttpResponse response = conn.receiveResponse(request); 
                 System.out.println("<< Response: " + response.getStatusLine());
                 System.out.println(EntityUtils.toString(response.getEntity()));
                 System.out.println("==============");

Modified: jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java?rev=357518&r1=357517&r2=357518&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
Sun Dec 18 14:08:00 2005
@@ -106,7 +106,7 @@
                 }
                 System.out.println(">> Request URI: " + request.getRequestLine().getUri());
                 conn.sendRequest(request);
-                HttpResponse response = conn.receiveResponse(request.getParams()); 
+                HttpResponse response = conn.receiveResponse(request); 
                 System.out.println("<< Response: " + response.getStatusLine());
                 System.out.println(EntityUtils.toString(response.getEntity()));
                 System.out.println("==============");

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpClientConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpClientConnection.java?rev=357518&r1=357517&r2=357518&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpClientConnection.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpClientConnection.java
Sun Dec 18 14:08:00 2005
@@ -61,8 +61,8 @@
 
     void sendRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, IOException;
 
-    HttpResponse receiveResponse(HttpParams params) throws HttpException, IOException;
+    HttpResponse receiveResponse(HttpRequest request) throws HttpException, IOException;
 
-    HttpResponse receiveResponse(HttpParams params, int timeout) throws HttpException, IOException;
+    HttpResponse receiveResponse(HttpRequest request, int timeout) throws HttpException,
IOException;
     
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/executor/HttpRequestExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/executor/HttpRequestExecutor.java?rev=357518&r1=357517&r2=357518&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/executor/HttpRequestExecutor.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/executor/HttpRequestExecutor.java
Sun Dec 18 14:08:00 2005
@@ -128,8 +128,7 @@
                         && request instanceof HttpEntityEnclosingRequest) {
                     // Do 'expect: continue' handshake
                     conn.sendRequestHeader((HttpEntityEnclosingRequest)request);
-                    response = conn.receiveResponse(request.getParams(), 
-                            WAIT_FOR_CONTINUE_MS);
+                    response = conn.receiveResponse(request, WAIT_FOR_CONTINUE_MS);
                     if (response == null) {
                         // No response. The 'expect: continue' is likely not supported
                         break;
@@ -152,7 +151,7 @@
                         new Boolean(true)); 
                 for (;;) {
                     // Loop until non 1xx resposne is received
-                    response = conn.receiveResponse(request.getParams());
+                    response = conn.receiveResponse(request);
                     int statuscode = response.getStatusLine().getStatusCode();
                     if (statuscode >= HttpStatus.SC_OK) {
                         break;

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=357518&r1=357517&r2=357518&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
Sun Dec 18 14:08:00 2005
@@ -228,38 +228,37 @@
                 this.datatransmitter);
     }
     
-    public HttpResponse receiveResponse(final HttpParams params) 
+    public HttpResponse receiveResponse(final HttpRequest request) 
             throws HttpException, IOException {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
+        if (request == null) {
+            throw new IllegalArgumentException("HTTP request may not be null");
         }
         assertOpen();
         // reset the data receiver
-        this.datareceiver.reset(params);
-        return readResponse(params);
+        this.datareceiver.reset(request.getParams());
+        return readResponse(request);
     }
 
-    public HttpResponse receiveResponse(final HttpParams params, int timeout) 
+    public HttpResponse receiveResponse(final HttpRequest request, int timeout) 
             throws HttpException, IOException {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
+        if (request == null) {
+            throw new IllegalArgumentException("HTTP request may not be null");
         }
         assertOpen();
         // reset the data receiver
-        this.datareceiver.reset(params);
+        this.datareceiver.reset(request.getParams());
         if (this.datareceiver.isDataAvailable(timeout)) {
-            return readResponse(params);
+            return readResponse(request);
         } else {
             return null;
         }
     }
 
-    protected HttpResponse readResponse(final HttpParams params)
+    protected HttpResponse readResponse(final HttpRequest request)
             throws HttpException, IOException {
-        this.datareceiver.reset(params);
-        HttpMutableResponse response = readResponseStatusLine(params);
+        HttpMutableResponse response = readResponseStatusLine(request.getParams());
         readResponseHeaders(response);
-        if (canResponseHaveBody(response)) {
+        if (canResponseHaveBody(request, response)) {
             readResponseBody(response);
         }
         return response;
@@ -336,7 +335,10 @@
         wirelog("<< [\\r][\\n]");
     }
     
-    protected boolean canResponseHaveBody(final HttpResponse response) {
+    protected boolean canResponseHaveBody(final HttpRequest request, final HttpResponse response)
{
+        if ("HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
+            return false;
+        }
         int status = response.getStatusLine().getStatusCode(); 
         return status >= HttpStatus.SC_OK 
             && status != HttpStatus.SC_NO_CONTENT 



Mime
View raw message