use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class HttpMessageLoggingInterceptorTest method logsRequestsAndResponses.
@Test
public void logsRequestsAndResponses() {
LiveHttpRequest request = get("/").version(HttpVersion.HTTP_1_1).header("ReqHeader", "ReqHeaderValue").cookies(requestCookie("ReqCookie", "ReqCookieValue")).build();
consume(interceptor.intercept(request, chain(response(OK).header("RespHeader", "RespHeaderValue").cookies(responseCookie("RespCookie", "RespCookieValue").build()))));
assertThat(responseLogSupport.log(), contains(loggingEvent(INFO, "requestId=" + request.id() + ", secure=true, origin=null, request=" + FORMATTED_REQUEST), loggingEvent(INFO, "requestId=" + request.id() + ", secure=true, response=" + FORMATTED_RESPONSE)));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class HttpMessageLoggingInterceptorTest method logsRequestsAndResponsesShort.
@Test
public void logsRequestsAndResponsesShort() {
interceptor = new HttpMessageLoggingInterceptor(false, httpMessageFormatter);
LiveHttpRequest request = get("/").header("ReqHeader", "ReqHeaderValue").cookies(requestCookie("ReqCookie", "ReqCookieValue")).build();
consume(interceptor.intercept(request, chain(response(OK).header("RespHeader", "RespHeaderValue").cookies(responseCookie("RespCookie", "RespCookieValue").build()))));
String requestPattern = "request=\\{version=HTTP/1.1, method=GET, uri=/, id=" + request.id() + "\\}";
String responsePattern = "response=\\{version=HTTP/1.1, status=200 OK\\}";
assertThat(responseLogSupport.log(), contains(loggingEvent(INFO, "requestId=" + request.id() + ", secure=true, origin=null, " + requestPattern), loggingEvent(INFO, "requestId=" + request.id() + ", secure=true, " + responsePattern)));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class UnexpectedRequestContentLengthRemoverTest method removesContentLengthIfBothContentLengthAndChunkedHeaderExists.
@Test
public void removesContentLengthIfBothContentLengthAndChunkedHeaderExists() throws Exception {
LiveHttpRequest request = get("/foo").header(CONTENT_LENGTH, "50").header(TRANSFER_ENCODING, CHUNKED).build();
LiveHttpRequest interceptedRequest = interceptRequest(request);
assertThat(interceptedRequest.contentLength(), isAbsent());
assertThat(interceptedRequest.chunked(), is(true));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class ViaHeaderAppendingInterceptorTest method appendsViaHeaderValueAtEndOfTheViaList.
@Test
public void appendsViaHeaderValueAtEndOfTheViaList() throws Exception {
LiveHttpRequest request = post("/foo").header(VIA, "1.0 ricky, 1.1 mertz, 1.0 lucy").build();
LiveHttpRequest interceptedRequest = interceptRequest(interceptor, request);
assertThat(interceptedRequest.headers().get(VIA), isValue("1.0 ricky, 1.1 mertz, 1.0 lucy, 1.1 styx"));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class ViaHeaderAppendingInterceptorTest method appendsHttp10RequestVersionInRequestViaHeader.
@Test
public void appendsHttp10RequestVersionInRequestViaHeader() throws Exception {
LiveHttpRequest request = post("/foo").version(HTTP_1_0).header(VIA, "").build();
LiveHttpRequest interceptedRequest = interceptRequest(interceptor, request);
assertThat(interceptedRequest.headers().get(VIA), isValue("1.0 styx"));
}
Aggregations