Search in sources :

Example 1 with ContentCodingHttpServiceFilter

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

the class ServiceTalkContentCodingTest method newServiceTalkServer.

private ServerContext newServiceTalkServer(final Scenario scenario, final Queue<Throwable> errors) throws Exception {
    HttpServerBuilder httpServerBuilder = HttpServers.forAddress(localAddress(0));
    StreamingHttpService service = (ctx, request, responseFactory) -> succeeded(buildResponse(responseFactory));
    StreamingHttpServiceFilterFactory filterFactory = REQ_FILTER.apply(scenario, errors);
    return httpServerBuilder.executionStrategy(defaultStrategy()).protocols(scenario.protocol.config).appendServiceFilter(new ContentCodingHttpServiceFilter(scenario.serverSupported, scenario.serverSupported)).appendServiceFilter(filterFactory).listenStreamingAndAwait(service);
}
Also used : TestUtils.assertNoAsyncErrors(io.servicetalk.test.resources.TestUtils.assertNoAsyncErrors) FilterableStreamingHttpClient(io.servicetalk.http.api.FilterableStreamingHttpClient) ContentCodec(io.servicetalk.encoding.api.ContentCodec) BiFunction(java.util.function.BiFunction) Collections.disjoint(java.util.Collections.disjoint) StreamingHttpServiceFilterFactory(io.servicetalk.http.api.StreamingHttpServiceFilterFactory) Collections.singletonList(java.util.Collections.singletonList) HttpExecutionStrategies.defaultStrategy(io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy) StreamingHttpClient(io.servicetalk.http.api.StreamingHttpClient) MethodSource(org.junit.jupiter.params.provider.MethodSource) BlockingHttpClient(io.servicetalk.http.api.BlockingHttpClient) HeaderUtils.encodingFor(io.servicetalk.encoding.api.internal.HeaderUtils.encodingFor) ContentCodingHttpServiceFilter(io.servicetalk.http.api.ContentCodingHttpServiceFilter) StreamingHttpClientFilter(io.servicetalk.http.api.StreamingHttpClientFilter) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) List(java.util.List) StreamingHttpService(io.servicetalk.http.api.StreamingHttpService) HttpSerializationProviders.textDeserializer(io.servicetalk.http.api.HttpSerializationProviders.textDeserializer) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Queue(java.util.Queue) Arrays.stream(java.util.Arrays.stream) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Identity.identity(io.servicetalk.encoding.api.Identity.identity) StreamingHttpResponse(io.servicetalk.http.api.StreamingHttpResponse) CharSequences.contentEquals(io.servicetalk.buffer.api.CharSequences.contentEquals) HttpSerializationProviders.textSerializer(io.servicetalk.http.api.HttpSerializationProviders.textSerializer) StreamingHttpRequester(io.servicetalk.http.api.StreamingHttpRequester) UNSUPPORTED_MEDIA_TYPE(io.servicetalk.http.api.HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE) StreamingHttpServiceFilter(io.servicetalk.http.api.StreamingHttpServiceFilter) HttpServiceContext(io.servicetalk.http.api.HttpServiceContext) Single.succeeded(io.servicetalk.concurrent.api.Single.succeeded) HttpSerializers.appSerializerUtf8FixLen(io.servicetalk.http.api.HttpSerializers.appSerializerUtf8FixLen) HttpSerializers.textSerializerUtf8(io.servicetalk.http.api.HttpSerializers.textSerializerUtf8) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) HttpServerBuilder(io.servicetalk.http.api.HttpServerBuilder) ContentCodingHttpRequesterFilter(io.servicetalk.http.api.ContentCodingHttpRequesterFilter) INTERNAL_SERVER_ERROR(io.servicetalk.http.api.HttpResponseStatus.INTERNAL_SERVER_ERROR) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) ServerContext(io.servicetalk.transport.api.ServerContext) Single(io.servicetalk.concurrent.api.Single) BlockingStreamingHttpClient(io.servicetalk.http.api.BlockingStreamingHttpClient) ACCEPT_ENCODING(io.servicetalk.http.api.HttpHeaderNames.ACCEPT_ENCODING) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Collectors.toList(java.util.stream.Collectors.toList) StreamingHttpResponseFactory(io.servicetalk.http.api.StreamingHttpResponseFactory) Single.failed(io.servicetalk.concurrent.api.Single.failed) StreamingHttpClientFilterFactory(io.servicetalk.http.api.StreamingHttpClientFilterFactory) CONTENT_ENCODING(io.servicetalk.http.api.HttpHeaderNames.CONTENT_ENCODING) HostAndPort(io.servicetalk.transport.api.HostAndPort) ContentCodingHttpServiceFilter(io.servicetalk.http.api.ContentCodingHttpServiceFilter) HttpServerBuilder(io.servicetalk.http.api.HttpServerBuilder) StreamingHttpService(io.servicetalk.http.api.StreamingHttpService) StreamingHttpServiceFilterFactory(io.servicetalk.http.api.StreamingHttpServiceFilterFactory)

Aggregations

CharSequences.contentEquals (io.servicetalk.buffer.api.CharSequences.contentEquals)1 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)1 Single (io.servicetalk.concurrent.api.Single)1 Single.failed (io.servicetalk.concurrent.api.Single.failed)1 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)1 ContentCodec (io.servicetalk.encoding.api.ContentCodec)1 Identity.identity (io.servicetalk.encoding.api.Identity.identity)1 HeaderUtils.encodingFor (io.servicetalk.encoding.api.internal.HeaderUtils.encodingFor)1 BlockingHttpClient (io.servicetalk.http.api.BlockingHttpClient)1 BlockingStreamingHttpClient (io.servicetalk.http.api.BlockingStreamingHttpClient)1 ContentCodingHttpRequesterFilter (io.servicetalk.http.api.ContentCodingHttpRequesterFilter)1 ContentCodingHttpServiceFilter (io.servicetalk.http.api.ContentCodingHttpServiceFilter)1 FilterableStreamingHttpClient (io.servicetalk.http.api.FilterableStreamingHttpClient)1 HttpExecutionStrategies.defaultStrategy (io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy)1 ACCEPT_ENCODING (io.servicetalk.http.api.HttpHeaderNames.ACCEPT_ENCODING)1 CONTENT_ENCODING (io.servicetalk.http.api.HttpHeaderNames.CONTENT_ENCODING)1 INTERNAL_SERVER_ERROR (io.servicetalk.http.api.HttpResponseStatus.INTERNAL_SERVER_ERROR)1 UNSUPPORTED_MEDIA_TYPE (io.servicetalk.http.api.HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE)1 HttpSerializationProviders.textDeserializer (io.servicetalk.http.api.HttpSerializationProviders.textDeserializer)1 HttpSerializationProviders.textSerializer (io.servicetalk.http.api.HttpSerializationProviders.textSerializer)1