incubator-awf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sleme...@apache.org
Subject svn commit: r1243289 - in /incubator/deft/trunk/src: main/java/org/apache/deft/web/http/HttpRequestImpl.java main/java/org/apache/deft/web/http/PartialHttpRequest.java test/java/org/apache/deft/web/http/HttpRequestImplTest.java
Date Sun, 12 Feb 2012 18:31:27 GMT
Author: slemesle
Date: Sun Feb 12 18:31:26 2012
New Revision: 1243289

URL: http://svn.apache.org/viewvc?rev=1243289&view=rev
Log:
Cleanup old fashion http parser

Removed:
    incubator/deft/trunk/src/main/java/org/apache/deft/web/http/PartialHttpRequest.java
Modified:
    incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java
    incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestImplTest.java

Modified: incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java?rev=1243289&r1=1243288&r2=1243289&view=diff
==============================================================================
--- incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java (original)
+++ incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java Sun Feb
12 18:31:26 2012
@@ -22,10 +22,8 @@ package org.apache.deft.web.http;
 import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
 import java.net.URLDecoder;
-import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Pattern;
 
@@ -33,18 +31,14 @@ import com.google.common.base.Charsets;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.Maps;
-import org.apache.deft.io.IOLoop;
 import org.apache.deft.io.buffer.DynamicByteBuffer;
-import org.apache.deft.util.ArrayUtil;
 import org.apache.deft.web.http.protocol.HttpVerb;
 
 /**
- * TODO SLM Cleanup old Parsing code 
+ *
  */
 public class HttpRequestImpl implements HttpRequest {
 
-    private IOLoop ioLoop;
-
     private  String requestLine;
     private  HttpVerb method;
     private  String requestedPath; // correct name?
@@ -71,13 +65,6 @@ public class HttpRequestImpl implements 
     public static final Pattern PARAM_STRING_PATTERN = Pattern.compile("\\&|;");
     /** Regex to parse out key/value pairs */
     public static final Pattern KEY_VALUE_PATTERN = Pattern.compile("=");
-    /** Regex to parse raw headers and body */
-    public static final Pattern RAW_VALUE_PATTERN = Pattern.compile("\\r\\n\\r\\n");
-    // TODO fix a better regexp for this
-    /** Regex to parse raw headers from body */
-    public static final Pattern HEADERS_BODY_PATTERN = Pattern.compile("\\r\\n");
-    /** Regex to parse header name and value */
-    public static final Pattern HEADER_VALUE_PATTERN = Pattern.compile(": ");
     /** Regex to split cookie header following RFC6265 Section 5.4 */
     public static final Pattern COOKIE_SEPARATOR_PATTERN = Pattern.compile(";");
 
@@ -103,86 +90,6 @@ public class HttpRequestImpl implements 
         body = null;
         initKeepAlive();
         parameters = parseParameters((pathFrags.length>1 ? pathFrags[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
-     * 
-     * @param requestLine The Http request text line
-     * @param headers The Http request headers
-     * @param body The Http request posted body
-     */
-    public HttpRequestImpl(String requestLine, Map<String, String> headers, String
body) {
-        this(requestLine, headers);
-        this.body = body;
-    }
-
-    public static HttpRequestImpl of(ByteBuffer buffer) {
-        try {
-            String raw = new String(buffer.array(), 0, buffer.limit(), Charsets.ISO_8859_1);
-            String[] headersAndBody = RAW_VALUE_PATTERN.split(raw);
-            String[] headerFields = HEADERS_BODY_PATTERN.split(headersAndBody[0]);
-            headerFields = ArrayUtil.dropFromEndWhile(headerFields, "");
-
-            String requestLine = headerFields[0];
-            Map<String, String> generalHeaders = new HashMap<String, String>();
-            for (int i = 1; i < headerFields.length; i++) {
-                String[] header = HEADER_VALUE_PATTERN.split(headerFields[i]);
-                generalHeaders.put(header[0].toLowerCase(), header[1]);
-            }
-
-            String body = "";
-            for (int i = 1; i < headersAndBody.length; ++i) { // First entry
-                // contains
-                // headers
-                body += headersAndBody[i];
-            }
-
-            if (requestLine.contains("POST") || requestLine.contains("PUT")) {
-                int contentLength = Integer.parseInt(generalHeaders.get("content-length"));
-                if (contentLength > body.length()) {
-                    String[] elements = REQUEST_LINE_PATTERN.split(requestLine);
-                    return new PartialHttpRequest(elements[0], requestLine, generalHeaders,
body);
-                }
-            }
-            return new HttpRequestImpl(requestLine, generalHeaders, body);
-        } catch (Exception t) {
-            return MalFormedHttpRequest.instance;
-        }
-    }
-
-    public static HttpRequestImpl continueParsing(ByteBuffer buffer, PartialHttpRequest unfinished)
{
-        String nextChunk = new String(buffer.array(), 0, buffer.limit(), Charsets.US_ASCII);
-        unfinished.appendBody(nextChunk);
-
-        int contentLength = Integer.parseInt(unfinished.getHeader("Content-Length"));
-        if (contentLength > unfinished.getBody().length()) {
-            return unfinished;
-        } else {
-            return new HttpRequestImpl(unfinished.getRequestLine(), unfinished.getHeaders(),
unfinished.getBody());
-        }
-    }
-
-    protected void setIOLoop(IOLoop ioLoop) {
-        this.ioLoop = ioLoop;
-    }
-
-    public IOLoop getIOLoop() {
-        return ioLoop;
     }
 
     @Override
@@ -328,6 +235,10 @@ public class HttpRequestImpl implements 
         return keepAlive;
     }
 
+    /**
+     * TODO SLM This should output the real request and use a StringBuilder
+     * @return
+     */
     @Override
     public String toString() {
         String result = "METHOD: " + method + "\n";
@@ -393,14 +304,10 @@ public class HttpRequestImpl implements 
     }
 
     protected void initKeepAlive() {
+        keepAlive = true;
         String connection = getHeader("Connection");
-
-        if ("keep-alive".equalsIgnoreCase(connection)) {
-            keepAlive = true;
-        } else if ("close".equalsIgnoreCase(connection) || requestLine.contains("1.0")) {
+        if ("close".equalsIgnoreCase(connection) || requestLine.contains("1.0")) {
             keepAlive = false;
-        } else {
-            keepAlive = true;
         }
     }
 
@@ -476,7 +383,7 @@ public class HttpRequestImpl implements 
     }
     
     public boolean expectContinue() {    	
-    	return (bodyBuffer != null && bodyBuffer.position() == 0) && headers.get("expect")
!= null;
+    	return (bodyBuffer == null || bodyBuffer.position() == 0) && headers.containsKey("expect");
     }
 
 }

Modified: incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestImplTest.java
URL: http://svn.apache.org/viewvc/incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestImplTest.java?rev=1243289&r1=1243288&r2=1243289&view=diff
==============================================================================
--- incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestImplTest.java (original)
+++ incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestImplTest.java Sun
Feb 12 18:31:26 2012
@@ -19,342 +19,17 @@
  */
 package org.apache.deft.web.http;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
-import org.apache.deft.util.ArrayUtil;
-import org.apache.deft.util.HttpRequestHelper;
-import org.apache.deft.util.HttpUtil;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class HttpRequestImplTest {
 
     @Test
-    public void testDeserializeHttpGetRequest() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addHeader("Host", "127.0.0.1:8080");
-        helper.addHeader("User-Agent", "curl/7.19.5 (i386-apple-darwin10.0.0) libcurl/7.19.5
zlib/1.2.3");
-        helper.addHeader("Accept", "*/*");
-        ByteBuffer bb1 = helper.getRequestAsByteBuffer();
-
-        helper = new HttpRequestHelper();
-        helper.addHeader("Host", "127.0.0.1:8080");
-        helper.addHeader("User-Agent",
-                "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.2) Gecko/20100316
Firefox/3.6.2");
-        helper.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
-        helper.addHeader("Accept-Language", "sv-se,sv;q=0.8,en-us;q=0.5,en;q=0.3");
-        helper.addHeader("Accept-Encoding", "gzip,deflate");
-        helper.addHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
-        helper.addHeader("Keep-Alive", "115");
-        helper.addHeader("Connection", "keep-alve");
-        ByteBuffer bb2 = helper.getRequestAsByteBuffer();
-
-        HttpRequest request1 = HttpRequestImpl.of(bb1);
-        HttpRequest request2 = HttpRequestImpl.of(bb2);
-
-        assertEquals("GET / HTTP/1.1", request1.getRequestLine());
-        assertEquals("GET / HTTP/1.1", request2.getRequestLine());
-
-        assertEquals(4, request1.getHeaders().size());
-        assertEquals(9, request2.getHeaders().size());
-
-        List<String> expectedHeaderNamesInRequest1 = Arrays.asList(new String[] { "User-Agent",
"Host", "Accept",
-                "From" });
-        for (String expectedHeaderName : expectedHeaderNamesInRequest1) {
-            assertTrue(request1.getHeaders().containsKey(expectedHeaderName.toLowerCase()));
-        }
-
-        List<String> expectedHeaderNamesInRequest2 = Arrays.asList(new String[] { "Host",
"User-Agent", "Accept",
-                "From", "Accept-Language", "Accept-Encoding", "Accept-Charset", "Keep-Alive",
"Connection" });
-        for (String expectedHeaderName : expectedHeaderNamesInRequest2) {
-            assertTrue(request2.getHeaders().containsKey(expectedHeaderName.toLowerCase()));
-        }
-
-        // TODO RS 100920 verify that the headers exist
-    }
-
-    public void testRemoveTrailingEmptyStrings() {
-        String fields1[] = new String[] { "a", "b", "c", "", "" };
-        String fields2[] = new String[] { "a", "b", "c" };
-
-        assertEquals(3, ArrayUtil.dropFromEndWhile(fields1, "").length);
-        assertEquals(3, ArrayUtil.dropFromEndWhile(fields2, "").length);
-    }
-
-    @Test
-    public void testSingleGetParameter() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("firstname", "jim");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-
-        assertEquals(1, request.getParameters().size());
-        assertEquals("jim", request.getParameter("firstname"));
-    }
-
-    @Test
-    public void testMultipleGetParameter() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("firstname", "jim");
-        helper.addGetParameter("lastname", "petersson");
-        helper.addGetParameter("city", "stockholm");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-
-        assertEquals(3, getSize(params));
-        assertEquals("jim", request.getParameter("firstname"));
-        assertEquals("petersson", request.getParameter("lastname"));
-        assertEquals("stockholm", request.getParameter("city"));
-    }
-
-    private int getSize(Map<String, Collection<String>> mmap) {
-        int size = 0;
-        for (Collection<String> values : mmap.values()) {
-            size += values.size();
-        }
-        return size;
-    }
-
-    @Test
-    public void testSingleParameterWithoutValue() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("firstname", null);
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-        assertEquals(0, getSize(params));
-        assertEquals(null, request.getParameter("firstname"));
-    }
-
-    @Test
-    public void testMultipleParametersWithoutValue() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("firstname", null);
-        helper.addGetParameter("lastName", "");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-
-        assertEquals(0, getSize(params));
-        assertEquals(null, request.getParameter("firstname"));
-        assertEquals(null, request.getParameter("lastName"));
-    }
-
-    @Test
-    public void testMultipleParametersWithAndWithoutValue() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("firstname", null);
-        helper.addGetParameter("lastName", "petersson");
-        helper.addGetParameter("city", "");
-        helper.addGetParameter("phoneno", "12345");
-        helper.addGetParameter("age", "30");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-
-        assertEquals(3, getSize(params));
-        assertEquals(null, request.getParameter("firstname"));
-        assertEquals("petersson", request.getParameter("lastName"));
-        assertEquals(null, request.getParameter("city"));
-        assertEquals("12345", request.getParameter("phoneno"));
-        assertEquals("30", request.getParameter("age"));
-    }
-
-    @Test
-    public void testSingleGetParameterMultipleValues() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("letters", "x");
-        helper.addGetParameter("letters", "y");
-        helper.addGetParameter("letters", "z");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-
-        assertEquals(3, getSize(params));
-        Collection<String> values = params.get("letters");
-        assertEquals(3, values.size());
-        assertTrue(values.contains("x"));
-        assertTrue(values.contains("y"));
-        assertTrue(values.contains("z"));
-    }
-
-    @Test
-    public void testMultipleGetParametersMultipleValues() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("letters", "x");
-        helper.addGetParameter("letters", "y");
-        helper.addGetParameter("letters", "z");
-        helper.addGetParameter("numbers", "23");
-        helper.addGetParameter("numbers", "54");
-        helper.addGetParameter("country", "swe");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-
-        assertEquals(6, getSize(params));
-        Collection<String> letters = params.get("letters");
-        Collection<String> numbers = params.get("numbers");
-        Collection<String> country = params.get("country");
-
-        assertEquals(3, letters.size());
-        assertEquals(2, numbers.size());
-        assertEquals(1, country.size());
-
-        assertTrue(letters.contains("x"));
-        assertTrue(letters.contains("y"));
-        assertTrue(letters.contains("z"));
-
-        assertTrue(numbers.contains("23"));
-        assertTrue(numbers.contains("54"));
-
-        assertTrue(country.contains("swe"));
-    }
-
-    @Test
-    public void testSingleGetParameterMultipleValuesIncludingNull() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("letters", "x");
-        helper.addGetParameter("letters", "y");
-        helper.addGetParameter("letters", null);
-        helper.addGetParameter("letters", "z");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-
-        assertEquals(3, getSize(params));
-        Collection<String> values = params.get("letters");
-        assertEquals(3, values.size());
-        assertTrue(values.contains("x"));
-        assertTrue(values.contains("y"));
-        assertTrue(values.contains("z"));
-    }
-
-    @Test
-    public void testEmptyParameters() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-        assertNotNull(params);
-        assertEquals(0, getSize(params));
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void testImmutableParameters() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addGetParameter("letter", "x");
-
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        Map<String, Collection<String>> params = request.getParameters();
-        params.put("not", new ArrayList<String>());
-    }
-
-    @Test
-    public void testHostVerification_exists_HTTP_1_0() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.setVersion("1.0");
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        boolean requestOk = HttpUtil.verifyRequest(request);
-        assertTrue(requestOk);
-    }
-
-    @Test
-    public void testHostVerification_nonExisting_HTTP_1_0() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.setVersion("1.0");
-        helper.removeHeader("Host");
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        boolean requestOk = HttpUtil.verifyRequest(request);
-        assertTrue(requestOk);
-    }
-
-    @Test
-    public void testHostVerification_exists_HTTP_1_1() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        boolean requestOk = HttpUtil.verifyRequest(request);
-        assertTrue(requestOk);
-    }
-
-    @Test
-    public void testHostVerification_nonExisting_HTTP_1_1() {
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.removeHeader("Host");
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-        boolean requestOk = HttpUtil.verifyRequest(request);
-        assertFalse(requestOk);
-    }
-
-    @Test
-    public void testGarbageRequest() {
-        HttpRequestImpl.of(ByteBuffer.wrap(new byte[] { 1, 1, 1, 1 } // garbage
-                ));
-    }
-
-    /**
-     * Ensure that header keys are converted to lower case, to facilitate
-     * case-insensitive retrieval through
-     * {@link HttpRequestImpl#getHeader(String)}.
-     */
-    @Test
-    public void testOfConvertsHeaderKeysToLowerCase() {
-
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addHeader("TESTKEY", "unimportant");
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-
-        assertFalse(request.getHeaders().containsKey("TESTKEY"));
-        assertTrue(request.getHeaders().containsKey("testkey"));
-    }
-
-    /**
-     * Ensure that the case of any header values is correctly maintained.
-     */
-    @Test
-    public void testOfMaintainsHeaderValueCase() {
-
-        String expected = "vAlUe";
-
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addHeader("TESTKEY", expected);
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-
-        String actual = request.getHeader("TESTKEY");
-        assertEquals(expected, actual);
-    }
-
-    /**
-     * Ensure that case for any key passed to the method is unimportant for its
-     * retrieval.
-     */
-    @Test
-    public void testGetHeader() {
-
-        String expected = "value";
-
-        HttpRequestHelper helper = new HttpRequestHelper();
-        helper.addHeader("TESTKEY", expected);
-        HttpRequest request = HttpRequestImpl.of(helper.getRequestAsByteBuffer());
-
-        assertEquals(expected, request.getHeader("TESTKEY"));
-        assertEquals(expected, request.getHeader("testkey"));
-    }
-
-    @Test
     public void testHttpRequestNoQueryString() {
         String requestLine = "GET /foobar HTTP/1.1 ";
-        HttpRequest request = new HttpRequestImpl(requestLine, new HashMap<String, String>());
+        HttpRequest request = new HttpRequestImpl(requestLine, new HashMap<String, String>
());
         Assert.assertEquals("/foobar", request.getRequestedPath());
     }
 
@@ -373,35 +48,30 @@ public class HttpRequestImplTest {
     }
 
     @Test
-    public void testNoCookies() {
-        HttpRequestHelper hrh = new HttpRequestHelper();
-        HttpRequest hr = HttpRequestImpl.of(hrh.getRequestAsByteBuffer());
-        Assert.assertEquals(0, hr.getCookies().size());
-    }
+    public void doNotExpectContinueWhenBodyNotEmptyWithExpectHeader(){
+        HttpRequestImpl request = new HttpRequestImpl();
+        request.pushToHeaders("content-length", "12");
+        request.pushToHeaders("expect", "niniin");
+        request.getContentLength();
+        request.getBodyBuffer().put("12345".getBytes());
+        Assert.assertFalse("Expect continue should be false when body is submitted", request.expectContinue());
 
-    @Test
-    public void testOneCookie() {
-        HttpRequestHelper hrh = new HttpRequestHelper();
-        hrh.addHeader("Cookie", "one=value");
-        HttpRequest hr = HttpRequestImpl.of(hrh.getRequestAsByteBuffer());
-        Assert.assertEquals("value", hr.getCookie("one"));
     }
 
     @Test
-    public void testOneCookieWithoutValue() {
-        HttpRequestHelper hrh = new HttpRequestHelper();
-        hrh.addHeader("Cookie", "one=");
-        HttpRequest hr = HttpRequestImpl.of(hrh.getRequestAsByteBuffer());
-        Assert.assertEquals("", hr.getCookie("one"));
+    public void expectContinueWhenBodyNotNullButEmptyWithExpectHeader(){
+        HttpRequestImpl request = new HttpRequestImpl();
+        request.pushToHeaders("content-length", "12");
+        request.pushToHeaders("expect", "niniin");
+        request.getContentLength();
+        Assert.assertTrue("Expect continue should be false when body bot submitted", request.expectContinue());
     }
 
     @Test
-    public void testMultipleCookies() {
-        HttpRequestHelper hrh = new HttpRequestHelper();
-        hrh.addHeader("Cookie", "one=value;two=value2");
-        HttpRequest hr = HttpRequestImpl.of(hrh.getRequestAsByteBuffer());
-        Assert.assertEquals("value", hr.getCookie("one"));
-        Assert.assertEquals("value2", hr.getCookie("two"));
+    public void expectContinueWhenBodyNullWithExpectHeader(){
+        HttpRequestImpl request = new HttpRequestImpl();
+        request.pushToHeaders("expect", "niniin");
+        request.getContentLength();
+        Assert.assertTrue("Expect continue should be false when body is submitted", request.expectContinue());
     }
-
 }



Mime
View raw message