Java Code Examples for io.netty.handler.codec.http.HttpResponseStatus#TEMPORARY_REDIRECT

The following examples show how to use io.netty.handler.codec.http.HttpResponseStatus#TEMPORARY_REDIRECT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MesosClientTest.java    From mesos-rxjava with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetUriFromRedirectResponse() throws Exception {
    final URI mesosUri = URI.create("http://127.1.0.1:5050/api/v1/scheduler");
    final DefaultHttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.TEMPORARY_REDIRECT);
    nettyResponse.headers().add("Location", "//127.1.0.2:5050");
    final HttpClientResponse<ByteBuf> response = new HttpClientResponse<>(
        nettyResponse,
        UnicastContentSubject.create(1000, TimeUnit.MILLISECONDS)
    );
    final URI uri = MesosClient.getUriFromRedirectResponse(mesosUri, response);
    assertThat(uri).isEqualTo(URI.create("http://127.1.0.2:5050/api/v1/scheduler"));
}
 
Example 2
Source File: Responses.java    From crate with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirectTo(String location) {
    var response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.TEMPORARY_REDIRECT);
    response.headers().add(HttpHeaderNames.LOCATION, location);
    HttpUtil.setContentLength(response, 0);
    return response;
}