Search in sources :

Example 1 with TEXT_PLAIN_UTF_8

use of io.servicetalk.http.api.HttpHeaderValues.TEXT_PLAIN_UTF_8 in project servicetalk by apple.

the class SslProvidersTest method setUp.

private void setUp(SslProvider serverSslProvider, SslProvider clientSslProvider, int payloadLength) throws Exception {
    payloadBody = randomString(payloadLength);
    serverContext = HttpServers.forAddress(localAddress(0)).sslConfig(new ServerSslConfigBuilder(DefaultTestCerts::loadServerPem, DefaultTestCerts::loadServerKey).provider(serverSslProvider).build()).listenBlockingAndAwait((ctx, request, responseFactory) -> {
        assertThat(ctx.sslSession(), is(notNullValue()));
        assertThat(request.path(), is("/path"));
        assertThat(request.headers().get(CONTENT_TYPE), is(TEXT_PLAIN_UTF_8));
        assertThat(request.payloadBody(textSerializerUtf8()), is("request-payload-body-" + payloadBody));
        return responseFactory.ok().payloadBody("response-payload-body-" + payloadBody, textSerializerUtf8());
    });
    client = HttpClients.forSingleAddress(serverHostAndPort(serverContext)).ioExecutor(NettyIoExecutors.createIoExecutor("client-io")).sslConfig(new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).peerHost(serverPemHostname()).provider(clientSslProvider).build()).buildBlocking();
}
Also used : ServerSslConfigBuilder(io.servicetalk.transport.api.ServerSslConfigBuilder) CONTENT_TYPE(io.servicetalk.http.api.HttpHeaderNames.CONTENT_TYPE) OPENSSL(io.servicetalk.transport.api.SslProvider.OPENSSL) SslProvider(io.servicetalk.transport.api.SslProvider) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) HttpSerializers.textSerializerUtf8(io.servicetalk.http.api.HttpSerializers.textSerializerUtf8) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) DefaultTestCerts(io.servicetalk.test.resources.DefaultTestCerts) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) JDK(io.servicetalk.transport.api.SslProvider.JDK) MethodSource(org.junit.jupiter.params.provider.MethodSource) BlockingHttpClient(io.servicetalk.http.api.BlockingHttpClient) NettyIoExecutors(io.servicetalk.transport.netty.NettyIoExecutors) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) ServerContext(io.servicetalk.transport.api.ServerContext) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) HttpResponse(io.servicetalk.http.api.HttpResponse) Arguments(org.junit.jupiter.params.provider.Arguments) OK(io.servicetalk.http.api.HttpResponseStatus.OK) DefaultTestCerts.serverPemHostname(io.servicetalk.test.resources.DefaultTestCerts.serverPemHostname) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) TEXT_PLAIN_UTF_8(io.servicetalk.http.api.HttpHeaderValues.TEXT_PLAIN_UTF_8) ClientSslConfigBuilder(io.servicetalk.transport.api.ClientSslConfigBuilder) Matchers.is(org.hamcrest.Matchers.is) DefaultTestCerts(io.servicetalk.test.resources.DefaultTestCerts) ClientSslConfigBuilder(io.servicetalk.transport.api.ClientSslConfigBuilder) ServerSslConfigBuilder(io.servicetalk.transport.api.ServerSslConfigBuilder)

Aggregations

BlockingHttpClient (io.servicetalk.http.api.BlockingHttpClient)1 CONTENT_TYPE (io.servicetalk.http.api.HttpHeaderNames.CONTENT_TYPE)1 TEXT_PLAIN_UTF_8 (io.servicetalk.http.api.HttpHeaderValues.TEXT_PLAIN_UTF_8)1 HttpResponse (io.servicetalk.http.api.HttpResponse)1 OK (io.servicetalk.http.api.HttpResponseStatus.OK)1 HttpSerializers.textSerializerUtf8 (io.servicetalk.http.api.HttpSerializers.textSerializerUtf8)1 DefaultTestCerts (io.servicetalk.test.resources.DefaultTestCerts)1 DefaultTestCerts.serverPemHostname (io.servicetalk.test.resources.DefaultTestCerts.serverPemHostname)1 ClientSslConfigBuilder (io.servicetalk.transport.api.ClientSslConfigBuilder)1 ServerContext (io.servicetalk.transport.api.ServerContext)1 ServerSslConfigBuilder (io.servicetalk.transport.api.ServerSslConfigBuilder)1 SslProvider (io.servicetalk.transport.api.SslProvider)1 JDK (io.servicetalk.transport.api.SslProvider.JDK)1 OPENSSL (io.servicetalk.transport.api.SslProvider.OPENSSL)1 NettyIoExecutors (io.servicetalk.transport.netty.NettyIoExecutors)1 AddressUtils.localAddress (io.servicetalk.transport.netty.internal.AddressUtils.localAddress)1 AddressUtils.serverHostAndPort (io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Stream (java.util.stream.Stream)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1