Package org.deftserver.web.http

Examples of org.deftserver.web.http.HttpRequest


  }

  @Test
  public void testEmptyParameters() {
    HttpRequestHelper helper = new HttpRequestHelper();
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());
    Map<String, Collection<String>> params = request.getParameters();
    assertNotNull(params);
    assertEquals(0, getSize(params));
  }
View Full Code Here


  @Test(expected=UnsupportedOperationException.class)
  public void testImmutableParameters() {
    HttpRequestHelper helper = new HttpRequestHelper();
    helper.addGetParameter("letter", "x");

    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());
    Map<String, Collection<String>> params = request.getParameters();
    params.put("not", new ArrayList<String>())
  }
View Full Code Here

  @Test
  public void testHostVerification_exists_HTTP_1_0() {
    HttpRequestHelper helper = new HttpRequestHelper();
    helper.setVersion("1.0");
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());
    boolean requestOk = HttpUtil.verifyRequest(request);
    assertTrue(requestOk);
  }
View Full Code Here

  @Test
  public void testHostVerification_nonExisting_HTTP_1_0() {
    HttpRequestHelper helper = new HttpRequestHelper();
    helper.setVersion("1.0");
    helper.removeHeader("Host");
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());
    boolean requestOk = HttpUtil.verifyRequest(request);
    assertTrue(requestOk);
  }
View Full Code Here

  }

  @Test
  public void testHostVerification_exists_HTTP_1_1() {
    HttpRequestHelper helper = new HttpRequestHelper();
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());
    boolean requestOk = HttpUtil.verifyRequest(request);
    assertTrue(requestOk);
  }
View Full Code Here

  @Test
  public void testHostVerification_nonExisting_HTTP_1_1() {
    HttpRequestHelper helper = new HttpRequestHelper();
    helper.removeHeader("Host");
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());
    boolean requestOk = HttpUtil.verifyRequest(request);
    assertFalse(requestOk);
  }
View Full Code Here

  @Test
  public void testOfConvertsHeaderKeysToLowerCase() {

    HttpRequestHelper helper = new HttpRequestHelper();
    helper.addHeader("TESTKEY", "unimportant");
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());

    assertFalse(request.getHeaders().containsKey("TESTKEY"));
    assertTrue(request.getHeaders().containsKey("testkey"));
  }
View Full Code Here

    String expected = "vAlUe";

    HttpRequestHelper helper = new HttpRequestHelper();
    helper.addHeader("TESTKEY", expected);
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());

    String actual = request.getHeader("TESTKEY");
    assertEquals(expected, actual);
  }
View Full Code Here

    String expected = "value";

    HttpRequestHelper helper = new HttpRequestHelper();
    helper.addHeader("TESTKEY", expected);
    HttpRequest request = HttpRequest.of(helper.getRequestAsByteBuffer());

    assertEquals(expected, request.getHeader("TESTKEY"));
    assertEquals(expected, request.getHeader("testkey"));
  }
View Full Code Here

  }
 
  @Test
  public void testHttpRequestNoQueryString() {
    String requestLine = "GET /foobar HTTP/1.1 ";
    HttpRequest request = new HttpRequest(requestLine, new HashMap<String, String>());
    Assert.assertEquals("/foobar", request.getRequestedPath());
  }
View Full Code Here

TOP

Related Classes of org.deftserver.web.http.HttpRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.