Search in sources :

Example 81 with StreamingHttpRequest

use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.

the class MultiAddressUrlHttpClientTest method requestWithRequestTargetWithoutScheme.

@Test
void requestWithRequestTargetWithoutScheme() {
    StreamingHttpRequest request = client.get(format("%s/200?param=value#tag", hostHeader));
    // no host header
    toSource(client.request(request)).subscribe(subscriber);
    assertThat(subscriber.awaitOnError(), is(instanceOf(MalformedURLException.class)));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Test(org.junit.jupiter.api.Test)

Example 82 with StreamingHttpRequest

use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.

the class MultiAddressUrlHttpClientTest method requestWithAbsoluteFormRequestTargetWithoutHostHeader.

@Test
void requestWithAbsoluteFormRequestTargetWithoutHostHeader() throws Exception {
    StreamingHttpRequest request = client.get(format("http://%s/200?param=value#tag", hostHeader));
    requestAndValidate(request, OK, "/200?param=value#tag");
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Test(org.junit.jupiter.api.Test)

Example 83 with StreamingHttpRequest

use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.

the class MultiAddressUrlHttpClientTest method requestWithIncorrectPortInAbsoluteFormRequestTarget.

@Test
void requestWithIncorrectPortInAbsoluteFormRequestTarget() {
    StreamingHttpRequest request = client.get(format("http://%s:-1/200?param=value#tag", serverHost));
    toSource(client.request(request)).subscribe(subscriber);
    assertThat(subscriber.awaitOnError(), is(instanceOf(IllegalArgumentException.class)));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Test(org.junit.jupiter.api.Test)

Example 84 with StreamingHttpRequest

use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.

the class MultiAddressUrlHttpClientTest method makeGetRequestAndValidate.

private static void makeGetRequestAndValidate(final String hostHeader, final HttpResponseStatus status) throws Exception {
    StreamingHttpRequest request = client.get(format("http://%s/%d?param=value#tag", hostHeader, status.code()));
    requestAndValidate(request, status, format("/%d?param=value#tag", status.code()));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest)

Example 85 with StreamingHttpRequest

use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.

the class MultiAddressUrlHttpClientTest method requestWithRelativeFormRequestTargetAndHostHeader.

@Test
void requestWithRelativeFormRequestTargetAndHostHeader() {
    StreamingHttpRequest request = client.get("/200?param=value");
    request.headers().set(HOST, hostHeader);
    toSource(client.request(request)).subscribe(subscriber);
    assertThat(subscriber.awaitOnError(), is(instanceOf(MalformedURLException.class)));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Test(org.junit.jupiter.api.Test)

Aggregations

StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)169 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)84 Test (org.junit.jupiter.api.Test)82 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)66 MethodSource (org.junit.jupiter.params.provider.MethodSource)47 Single (io.servicetalk.concurrent.api.Single)35 Buffer (io.servicetalk.buffer.api.Buffer)33 StreamingHttpClient (io.servicetalk.http.api.StreamingHttpClient)32 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)25 HttpServiceContext (io.servicetalk.http.api.HttpServiceContext)23 StreamingHttpResponseFactory (io.servicetalk.http.api.StreamingHttpResponseFactory)23 Nullable (javax.annotation.Nullable)22 InetSocketAddress (java.net.InetSocketAddress)21 OK (io.servicetalk.http.api.HttpResponseStatus.OK)20 StreamingHttpServiceFilter (io.servicetalk.http.api.StreamingHttpServiceFilter)19 CountDownLatch (java.util.concurrent.CountDownLatch)19 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)18 HttpHeaders (io.servicetalk.http.api.HttpHeaders)17 ServerContext (io.servicetalk.transport.api.ServerContext)17 AddressUtils.localAddress (io.servicetalk.transport.netty.internal.AddressUtils.localAddress)17