incubator-deft-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmee...@apache.org
Subject svn commit: r1153598 - in /incubator/deft/sandbox/src/main/java/org/deftserver/web/http: HttpRequestImpl.java PartialHttpRequest.java
Date Wed, 03 Aug 2011 17:56:35 GMT
Author: jmeehan
Date: Wed Aug  3 17:56:34 2011
New Revision: 1153598

URL: http://svn.apache.org/viewvc?rev=1153598&view=rev
Log:
DEFT-153 - Handle large bodies with PUT requests.

Modified:
    incubator/deft/sandbox/src/main/java/org/deftserver/web/http/HttpRequestImpl.java
    incubator/deft/sandbox/src/main/java/org/deftserver/web/http/PartialHttpRequest.java

Modified: incubator/deft/sandbox/src/main/java/org/deftserver/web/http/HttpRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/deft/sandbox/src/main/java/org/deftserver/web/http/HttpRequestImpl.java?rev=1153598&r1=1153597&r2=1153598&view=diff
==============================================================================
--- incubator/deft/sandbox/src/main/java/org/deftserver/web/http/HttpRequestImpl.java (original)
+++ incubator/deft/sandbox/src/main/java/org/deftserver/web/http/HttpRequestImpl.java Wed
Aug  3 17:56:34 2011
@@ -91,6 +91,19 @@ public class HttpRequestImpl implements 
         parameters = parseParameters(elements[1]);
     }
 
+    public HttpRequestImpl(String method, String fullUrl, String version, Map<String,
String> headers,
+            ImmutableMultimap<String, String> params) {
+        requestLine = method + " " + fullUrl + " " + version;
+        this.method = HttpVerb.valueOf(method);
+        String[] pathFrags = QUERY_STRING_PATTERN.split(fullUrl);
+        requestedPath = pathFrags[0];
+        this.version = version;
+        this.headers = headers;
+        body = null;
+        initKeepAlive();
+        parameters = params;
+    }
+
     /**
      * Creates a new HttpRequest
      * 
@@ -124,10 +137,11 @@ public class HttpRequestImpl implements 
                 body += headersAndBody[i];
             }
 
-            if (requestLine.contains("POST")) {
+            if (requestLine.contains("POST") || requestLine.contains("PUT")) {
                 int contentLength = Integer.parseInt(generalHeaders.get("content-length"));
                 if (contentLength > body.length()) {
-                    return new PartialHttpRequest(requestLine, generalHeaders, body);
+                    String[] elements = REQUEST_LINE_PATTERN.split(requestLine);
+                    return new PartialHttpRequest(elements[0], requestLine, generalHeaders,
body);
                 }
             }
             return new HttpRequestImpl(requestLine, generalHeaders, body);

Modified: incubator/deft/sandbox/src/main/java/org/deftserver/web/http/PartialHttpRequest.java
URL: http://svn.apache.org/viewvc/incubator/deft/sandbox/src/main/java/org/deftserver/web/http/PartialHttpRequest.java?rev=1153598&r1=1153597&r2=1153598&view=diff
==============================================================================
--- incubator/deft/sandbox/src/main/java/org/deftserver/web/http/PartialHttpRequest.java (original)
+++ incubator/deft/sandbox/src/main/java/org/deftserver/web/http/PartialHttpRequest.java Wed
Aug  3 17:56:34 2011
@@ -25,15 +25,14 @@ import java.util.Map;
  * Represents an unfinished "dummy" HTTP request, e.g, an HTTP POST request
  * where the entire payload hasn't been received. (E.g. because the size of the
  * underlying (OS) socket's read buffer has a fixed size.)
- * 
  */
 public class PartialHttpRequest extends HttpRequestImpl {
 
     private final String requestLine;
     private String unfinishedBody;
 
-    public PartialHttpRequest(String requestLine, Map<String, String> generalHeaders,
String body) {
-        super("POST <> Unfinished request\r\n", generalHeaders);
+    public PartialHttpRequest(String method, String requestLine, Map<String, String>
generalHeaders, String body) {
+        super(method, "<>", "Unfinished request\r\n", generalHeaders, null);
         this.requestLine = requestLine;
         unfinishedBody = body;
     }



Mime
View raw message