use of com.netflix.zuul.message.http.HttpResponseMessageImpl in project zuul by Netflix.
the class ZuulFilterChainRunnerTest method before.
@Before
public void before() {
SessionContext context = new SessionContext();
Headers headers = new Headers();
ChannelHandlerContext chc = mock(ChannelHandlerContext.class);
when(chc.executor()).thenReturn(ImmediateEventExecutor.INSTANCE);
context.put(NETTY_SERVER_CHANNEL_HANDLER_CONTEXT, chc);
request = new HttpRequestMessageImpl(context, "http", "GET", "/foo/bar", new HttpQueryParams(), headers, "127.0.0.1", "http", 8080, "server123");
request.storeInboundRequest();
response = new HttpResponseMessageImpl(context, request, 200);
}
use of com.netflix.zuul.message.http.HttpResponseMessageImpl in project zuul by Netflix.
the class HttpUtilsTest method getBodySizeIfKnown_returnsResponseBodySize.
@Test
public void getBodySizeIfKnown_returnsResponseBodySize() {
SessionContext context = new SessionContext();
Headers headers = new Headers();
HttpQueryParams queryParams = new HttpQueryParams();
HttpRequestMessage request = new HttpRequestMessageImpl(context, "http", "GET", "/path", queryParams, headers, "127.0.0.1", "scheme", 6666, "server-name");
request.storeInboundRequest();
HttpResponseMessage response = new HttpResponseMessageImpl(context, request, 200);
response.setBodyAsText("Hello world");
assertThat(HttpUtils.getBodySizeIfKnown(response)).isEqualTo(Integer.valueOf(11));
}
use of com.netflix.zuul.message.http.HttpResponseMessageImpl in project zuul by Netflix.
the class DebugTest method setup.
@Before
public void setup() {
ctx = new SessionContext();
headers = new Headers();
headers.add("lah", "deda");
params = new HttpQueryParams();
params.add("k1", "v1");
request = new HttpRequestBuilder(ctx).withMethod(HttpMethod.POST).withUri("/some/where").withHeaders(headers).withQueryParams(params).build();
request.setBodyAsText("some text");
request.storeInboundRequest();
response = new HttpResponseMessageImpl(ctx, headers, request, 200);
response.setBodyAsText("response text");
}
use of com.netflix.zuul.message.http.HttpResponseMessageImpl in project zuul by Netflix.
the class ProxyEndpoint method handleError.
private void handleError(final Throwable cause) {
final ZuulException ze = (cause instanceof ZuulException) ? (ZuulException) cause : requestAttemptFactory.mapNettyToOutboundException(cause, context);
LOG.debug("Proxy endpoint failed.", cause);
if (!startedSendingResponseToClient) {
startedSendingResponseToClient = true;
zuulResponse = new HttpResponseMessageImpl(context, zuulRequest, ze.getStatusCode());
// TODO - why close the connection? maybe don't always want this to happen ...
zuulResponse.getHeaders().add("Connection", "close");
zuulResponse.finishBufferedBodyIfIncomplete();
invokeNext(zuulResponse);
} else {
channelCtx.fireExceptionCaught(ze);
}
}
use of com.netflix.zuul.message.http.HttpResponseMessageImpl in project zuul by Netflix.
the class ProxyEndpoint method handleNoOriginSelected.
private void handleNoOriginSelected() {
StatusCategoryUtils.setStatusCategory(context, SUCCESS_LOCAL_NO_ROUTE);
startedSendingResponseToClient = true;
zuulResponse = new HttpResponseMessageImpl(context, zuulRequest, 404);
zuulResponse.finishBufferedBodyIfIncomplete();
invokeNext(zuulResponse);
}
Aggregations