Ejemplo n.º 1
0
  @Test
  public void testGetsStringRequestFromBufferedReader() throws IOException {
    String request =
        "GET / HTTP/1.1\n" + "Host: localhost:5000\n" + "Accept-Language: en-US,en;q=0.8\r\n\r\n";

    BufferedReader bufferedReader = new BufferedReader(new StringReader(request));
    HashMap state = new HashMap();
    RequestHandler requestHandler = new RequestHandler(bufferedReader, state);
    requestHandler.readHead();

    assertEquals(
        ("GET / HTTP/1.1\n" + "Host: localhost:5000\n" + "Accept-Language: en-US,en;q=0.8\n"),
        requestHandler.getHead());
  }
Ejemplo n.º 2
0
 @Test
 public void testSplitBodyFromHead() throws UnsupportedEncodingException {
   String request =
       "GET / HTTP/1.1\n"
           + "Host: localhost:5000\n"
           + "Accept-Language: en-US,en;q=0.8\r\n\r\n"
           + "data=cosby";
   BufferedReader bufferedReader = new BufferedReader(new StringReader(request));
   HashMap state = new HashMap();
   RequestHandler requestHandler = new RequestHandler(bufferedReader, state);
   requestHandler.parseRequest(request);
   assertEquals(
       "GET / HTTP/1.1\n" + "Host: localhost:5000\n" + "Accept-Language: en-US,en;q=0.8",
       requestHandler.getHead());
 }