MesosClient { @NotNull static URI getUriFromRedirectResponse(final @NotNull URI mesosUri, @NotNull final HttpClientResponse<ByteBuf> redirectResponse) { if (redirectResponse.getStatus().equals(HttpResponseStatus.TEMPORARY_REDIRECT)) { final String location = redirectResponse.getHeaders().get("Location"); final URI newUri = resolveRelativeUri(mesosUri, location); LOGGER.info("Using new Mesos URI: {}", newUri); return newUri; } else { LOGGER.info("Continuing with Mesos URI as-is"); return mesosUri; } } MesosClient(
        @NotNull final URI mesosUri,
        @NotNull final Function<Class<?>, UserAgentEntry> applicationUserAgentEntry,
        @NotNull final MessageCodec<Send> sendCodec,
        @NotNull final MessageCodec<Receive> receiveCodec,
        @NotNull final Send subscribe,
        @NotNull final Function<Observable<Receive>, Observable<Optional<SinkOperation<Send>>>> streamProcessor,
        @NotNull final  Observable.Transformer<byte[], byte[]> backpressureTransformer
    ); @NotNull AwaitableSubscription openStream();  }
@Test public void testGetUriFromRedirectResponse() throws Exception { final URI mesosUri = URI.create("http: final DefaultHttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.TEMPORARY_REDIRECT); nettyResponse.headers().add("Location", " 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: }
@Test public void testGetUriFromRedirectResponse_404() throws Exception { final URI mesosUri = URI.create("http: final DefaultHttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND); 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: }
@Test public void testGetUriFromRedirectResponse_200() throws Exception { final URI mesosUri = URI.create("http: final DefaultHttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); 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: }