hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r692504 - in /httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message: BasicHttpEntityEnclosingRequest.java BasicHttpRequest.java
Date Fri, 05 Sep 2008 18:08:23 GMT
Author: olegk
Date: Fri Sep  5 11:08:22 2008
New Revision: 692504

URL: http://svn.apache.org/viewvc?rev=692504&view=rev
Log:
Added method to change request URI

Modified:
    httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java
    httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpRequest.java

Modified: httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java?rev=692504&r1=692503&r2=692504&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java
(original)
+++ httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java
Fri Sep  5 11:08:22 2008
@@ -58,7 +58,7 @@
 
     public BasicHttpEntityEnclosingRequest(final String method, final String uri, 
             final ProtocolVersion ver) {
-        this(new BasicRequestLine(method, uri, ver));
+        super(method, uri, ver);
     }
 
     public BasicHttpEntityEnclosingRequest(final RequestLine requestline) {

Modified: httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpRequest.java?rev=692504&r1=692503&r2=692504&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpRequest.java
(original)
+++ httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpRequest.java
Fri Sep  5 11:08:22 2008
@@ -47,11 +47,12 @@
  */
 public class BasicHttpRequest extends AbstractHttpMessage implements HttpRequest {
     
-    private final RequestLine requestline;
-    private final String method;
-    private final String uri;
+    private RequestLine requestline;
+    private String method;
+    private String uri;
+    private ProtocolVersion ver;
         
-    public BasicHttpRequest(final String method, final String uri) {
+    public BasicHttpRequest(final String method, final String uri, final ProtocolVersion
ver) {
         super();
         if (method == null) {
             throw new IllegalArgumentException("Method name may not be null");
@@ -61,13 +62,10 @@
         }
         this.method = method;
         this.uri = uri;
+        this.ver = ver;
         this.requestline = null;
     }
 
-    public BasicHttpRequest(final String method, final String uri, final ProtocolVersion
ver) {
-        this(new BasicRequestLine(method, uri, ver));
-    }
-
     public BasicHttpRequest(final RequestLine requestline) {
         super();
         if (requestline == null) {
@@ -76,23 +74,39 @@
         this.requestline = requestline;
         this.method = requestline.getMethod();
         this.uri = requestline.getUri();
+        this.ver = requestline.getProtocolVersion();
+    }
+
+    public BasicHttpRequest(final String method, final String uri) {
+        this(method, uri, null);
     }
 
     public ProtocolVersion getProtocolVersion() {
-        if (this.requestline != null) {
-            return this.requestline.getProtocolVersion();
-        } else {
-            return HttpProtocolParams.getVersion(getParams());
+        if (this.ver == null) {
+            this.ver = HttpProtocolParams.getVersion(getParams());
         }
+        return this.ver;
     }
     
     public RequestLine getRequestLine() {
-        if (this.requestline != null) {
-            return this.requestline;
-        } else {
-            ProtocolVersion ver = HttpProtocolParams.getVersion(getParams());
-            return new BasicRequestLine(this.method, this.uri, ver);
+        if (this.requestline == null) {
+            this.requestline = new BasicRequestLine(this.method, this.uri, 
+                    getProtocolVersion());
+        }
+        return this.requestline;
+    }
+    
+    public void setUri(final String uri) {
+        if (uri == null) {
+            throw new IllegalArgumentException("Request URI may not be null");
         }
+        this.uri = uri;
+        this.requestline = null;
+    }
+    
+    public void setProtocolVersion(final ProtocolVersion ver) {
+        this.ver = ver;
+        this.requestline = null;
     }
     
 }



Mime
View raw message