Search in sources :

Example 1 with ConvertAscii

use of org.webpieces.httpparser.impl.ConvertAscii in project webpieces by deanhiller.

the class TestRequestParsing method testAsciiConverter.

@Test
public void testAsciiConverter() {
    HttpRequest request = createPostRequest();
    byte[] payload = unwrap(parser.marshalToByteBuffer(state, request));
    ConvertAscii converter = new ConvertAscii();
    String readableForm = converter.convertToReadableForm(payload);
    String expected = "POST\\s http://myhost.com\\s HTTP/1.1\\r\\n\r\n" + "Accept:\\s CooolValue\\r\\n\r\n" + "CustomerHEADER:\\s betterValue\\r\\n\r\n" + "\\r\\n\r\n";
    Assert.assertEquals(expected, readableForm);
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) ConvertAscii(org.webpieces.httpparser.impl.ConvertAscii) Test(org.junit.Test)

Example 2 with ConvertAscii

use of org.webpieces.httpparser.impl.ConvertAscii in project webpieces by deanhiller.

the class TestResponseParsing method testAsciiConverter.

@Test
public void testAsciiConverter() {
    HttpResponse response = createOkResponse();
    byte[] payload = unwrap(parser.marshalToByteBuffer(state, response));
    ConvertAscii converter = new ConvertAscii();
    String readableForm = converter.convertToReadableForm(payload);
    Assert.assertEquals("HTTP/1.1\\s 200\\s OK\\r\\n\r\n" + "Accept:\\s CooolValue\\r\\n\r\n" + "CustomerHEADER:\\s betterValue\\r\\n\r\n" + "\\r\\n\r\n", readableForm);
}
Also used : ConvertAscii(org.webpieces.httpparser.impl.ConvertAscii) HttpResponse(org.webpieces.httpparser.api.dto.HttpResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ConvertAscii (org.webpieces.httpparser.impl.ConvertAscii)2 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)1 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)1