use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testRedirectRawRelativeUrl.
@Test
public void testRedirectRawRelativeUrl() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/rawurlredirect");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
Assert.assertEquals(0, response.getBody().getReadableSize());
Assert.assertEquals("http://myhost.com/myroute", response.getRedirectUrl());
}
use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testRedirectRawAbsoluteUrl.
@Test
public void testRedirectRawAbsoluteUrl() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/rawabsoluteurlredirect");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
Assert.assertEquals(0, response.getBody().getReadableSize());
Assert.assertEquals("https://something.com/hi", response.getRedirectUrl());
}
use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testRedirect.
@Test
public void testRedirect() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
Assert.assertEquals(0, response.getBody().getReadableSize());
Assert.assertEquals("http://myhost.com/myroute", response.getRedirectUrl());
}
use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testJsonFile.
@Test
public void testJsonFile() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/somejson");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("red");
response.assertContentType("application/json");
}
use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testAbsoluteHtmlPath.
@Test
public void testAbsoluteHtmlPath() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/myroute2");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("This is the first raw html page");
response.assertContentType("text/html; charset=utf-8");
List<Header> headers = response.getResponse().getHeaderLookupStruct().getHeaders(KnownHeaderName.CONTENT_TYPE);
Assert.assertEquals(1, headers.size());
}
Aggregations