Search in sources :

Example 26 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 27 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 28 with StreamingHttpRequest

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

the class ContentLengthTest method shouldCalculateRequestContentLengthFromTwoItemPublisher.

@Test
void shouldCalculateRequestContentLengthFromTwoItemPublisher() throws Exception {
    StreamingHttpRequest request = newAggregatedRequest().toStreamingRequest().payloadBody(from("Hello", "World"), appSerializerUtf8FixLen());
    setRequestContentLengthAndVerify(request, contentEqualTo("18"));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Test(org.junit.jupiter.api.Test)

Example 29 with StreamingHttpRequest

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

the class ContentLengthTest method shouldNotCalculateRequestContentLengthFromEmptyPublisher.

private static void shouldNotCalculateRequestContentLengthFromEmptyPublisher(HttpRequestMethod method) throws Exception {
    StreamingHttpRequest request = newAggregatedRequest(method).toStreamingRequest().payloadBody(Publisher.empty());
    setRequestContentLengthAndVerify(request, nullValue(CharSequence.class));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest)

Example 30 with StreamingHttpRequest

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

the class ContentLengthTest method shouldCalculateRequestContentLengthFromMultipleItemPublisher.

@Test
void shouldCalculateRequestContentLengthFromMultipleItemPublisher() throws Exception {
    StreamingHttpRequest request = newAggregatedRequest().toStreamingRequest().payloadBody(from("Hello", " ", "World", "!"), appSerializerUtf8FixLen());
    setRequestContentLengthAndVerify(request, contentEqualTo("28"));
}
Also used : StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Test(org.junit.jupiter.api.Test)

Aggregations

StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)167 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)83 Test (org.junit.jupiter.api.Test)78 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)65 MethodSource (org.junit.jupiter.params.provider.MethodSource)47 Single (io.servicetalk.concurrent.api.Single)34 Buffer (io.servicetalk.buffer.api.Buffer)33 StreamingHttpClient (io.servicetalk.http.api.StreamingHttpClient)31 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)24 HttpServiceContext (io.servicetalk.http.api.HttpServiceContext)22 StreamingHttpResponseFactory (io.servicetalk.http.api.StreamingHttpResponseFactory)22 Nullable (javax.annotation.Nullable)21 OK (io.servicetalk.http.api.HttpResponseStatus.OK)20 InetSocketAddress (java.net.InetSocketAddress)20 StreamingHttpServiceFilter (io.servicetalk.http.api.StreamingHttpServiceFilter)19 CountDownLatch (java.util.concurrent.CountDownLatch)19 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)17 HttpHeaders (io.servicetalk.http.api.HttpHeaders)17 ServerContext (io.servicetalk.transport.api.ServerContext)16 AddressUtils.localAddress (io.servicetalk.transport.netty.internal.AddressUtils.localAddress)16