Search in sources :

Example 6 with Publisher

use of io.servicetalk.concurrent.api.Publisher in project servicetalk by apple.

the class AbstractStreamingHttpConnection method request.

@Override
public Single<StreamingHttpResponse> request(final StreamingHttpRequest request) {
    return defer(() -> {
        Publisher<Object> flatRequest;
        // See https://tools.ietf.org/html/rfc7230#section-3.3.3
        if (canAddRequestContentLength(request)) {
            flatRequest = setRequestContentLength(connectionContext().protocol(), request);
        } else {
            if (emptyMessageBody(request, request.messageBody())) {
                flatRequest = flatEmptyMessage(connectionContext().protocol(), request, request.messageBody());
            } else {
                // Defer subscribe to the messageBody until transport requests it to allow clients retry failed
                // requests with non-replayable messageBody
                flatRequest = Single.<Object>succeeded(request).concat(request.messageBody(), true);
                if (shouldAppendTrailers(connectionContext().protocol(), request)) {
                    flatRequest = flatRequest.scanWith(HeaderUtils::appendTrailersMapper);
                }
            }
            addRequestTransferEncodingIfNecessary(request);
        }
        final HttpExecutionStrategy strategy = requestExecutionStrategy(request, executionContext().executionStrategy());
        if (strategy.isSendOffloaded()) {
            flatRequest = flatRequest.subscribeOn(connectionContext.executionContext().executor(), IoThreadFactory.IoThread::currentThreadIsIoThread);
        }
        Single<StreamingHttpResponse> resp = invokeClient(flatRequest, determineFlushStrategyForApi(request));
        if (strategy.isMetadataReceiveOffloaded()) {
            resp = resp.publishOn(connectionContext.executionContext().executor(), IoThreadFactory.IoThread::currentThreadIsIoThread);
        }
        if (strategy.isDataReceiveOffloaded()) {
            resp = resp.map(response -> response.transformMessageBody(payload -> payload.publishOn(connectionContext.executionContext().executor(), IoThreadFactory.IoThread::currentThreadIsIoThread)));
        }
        return resp.shareContextOnSubscribe();
    });
}
Also used : FlushStrategy(io.servicetalk.transport.netty.internal.FlushStrategy) HeaderUtils.canAddRequestContentLength(io.servicetalk.http.netty.HeaderUtils.canAddRequestContentLength) StreamingHttpResponse(io.servicetalk.http.api.StreamingHttpResponse) HttpRequestMethod(io.servicetalk.http.api.HttpRequestMethod) Publisher(io.servicetalk.concurrent.api.Publisher) StreamingHttpResponses.newTransportResponse(io.servicetalk.http.api.StreamingHttpResponses.newTransportResponse) ConsumableEvent(io.servicetalk.client.api.ConsumableEvent) HttpResponseMetaData(io.servicetalk.http.api.HttpResponseMetaData) HttpApiConversions.isSafeToAggregate(io.servicetalk.http.api.HttpApiConversions.isSafeToAggregate) FilterableStreamingHttpConnection(io.servicetalk.http.api.FilterableStreamingHttpConnection) FlushStrategies.flushOnEnd(io.servicetalk.transport.netty.internal.FlushStrategies.flushOnEnd) HttpMetaData(io.servicetalk.http.api.HttpMetaData) IoThreadFactory(io.servicetalk.transport.api.IoThreadFactory) Single.succeeded(io.servicetalk.concurrent.api.Single.succeeded) HttpApiConversions.isPayloadEmpty(io.servicetalk.http.api.HttpApiConversions.isPayloadEmpty) Objects.requireNonNull(java.util.Objects.requireNonNull) HttpExecutionStrategy(io.servicetalk.http.api.HttpExecutionStrategy) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) NettyConnectionContext(io.servicetalk.transport.netty.internal.NettyConnectionContext) HeaderUtils.addRequestTransferEncodingIfNecessary(io.servicetalk.http.netty.HeaderUtils.addRequestTransferEncodingIfNecessary) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) ClientInvoker(io.servicetalk.http.api.ClientInvoker) HttpConnectionContext(io.servicetalk.http.api.HttpConnectionContext) Nullable(javax.annotation.Nullable) HttpExecutionContext(io.servicetalk.http.api.HttpExecutionContext) HeaderUtils.flatEmptyMessage(io.servicetalk.http.netty.HeaderUtils.flatEmptyMessage) Executors.immediate(io.servicetalk.concurrent.api.Executors.immediate) StreamingHttpRequestResponseFactory(io.servicetalk.http.api.StreamingHttpRequestResponseFactory) Single.defer(io.servicetalk.concurrent.api.Single.defer) HeaderUtils.setRequestContentLength(io.servicetalk.http.netty.HeaderUtils.setRequestContentLength) Single(io.servicetalk.concurrent.api.Single) HeaderUtils.emptyMessageBody(io.servicetalk.http.netty.HeaderUtils.emptyMessageBody) HeaderUtils.shouldAppendTrailers(io.servicetalk.http.netty.HeaderUtils.shouldAppendTrailers) Completable(io.servicetalk.concurrent.api.Completable) HTTP_EXECUTION_STRATEGY_KEY(io.servicetalk.http.api.HttpContextKeys.HTTP_EXECUTION_STRATEGY_KEY) HttpEventKey(io.servicetalk.http.api.HttpEventKey) HttpRequestMetaData(io.servicetalk.http.api.HttpRequestMetaData) IgnoreConsumedEvent(io.servicetalk.client.api.internal.IgnoreConsumedEvent) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) StreamingHttpResponseFactory(io.servicetalk.http.api.StreamingHttpResponseFactory) REQ_EXPECT_CONTINUE(io.servicetalk.http.netty.HeaderUtils.REQ_EXPECT_CONTINUE) HttpHeadersFactory(io.servicetalk.http.api.HttpHeadersFactory) IoThreadFactory(io.servicetalk.transport.api.IoThreadFactory) HttpExecutionStrategy(io.servicetalk.http.api.HttpExecutionStrategy) StreamingHttpResponse(io.servicetalk.http.api.StreamingHttpResponse)

Example 7 with Publisher

use of io.servicetalk.concurrent.api.Publisher in project servicetalk by apple.

the class HelloWorldJaxRsResource method randomHello.

/**
 * Resource that only relies on {@link Single}/{@link Publisher} for consuming and producing data,
 * and returns a JAX-RS {@link Response} in order to set its status.
 * No OIO adaptation is involved when requests are dispatched to it,
 * allowing it to fully benefit from ReactiveStream's features like flow control.
 * Behind the scene, ServiceTalk's aggregation mechanism is used to provide the resource with a
 * {@link Single Single&lt;Buffer&gt;} that contains the whole request entity as a {@link Buffer}.
 * Note that the {@link ConnectionContext} could also be injected into a class-level {@code @Context} field.
 * <p>
 * Test with:
 * <pre>
 * curl -i -H 'content-type: text/plain' -d 'kitty' http://localhost:8080/greetings/random-hello
 * </pre>
 *
 * @param who the recipient of the greetings.
 * @param ctx the {@link ConnectionContext}.
 * @return greetings as a JAX-RS {@link Response}.
 */
@POST
@Path("random-hello")
@Consumes(TEXT_PLAIN)
@Produces(TEXT_PLAIN)
public Response randomHello(final Single<Buffer> who, @Context final ConnectionContext ctx) {
    if (random() < .5) {
        return accepted("greetings accepted, call again for a response").build();
    }
    final BufferAllocator allocator = ctx.executionContext().bufferAllocator();
    final Publisher<Buffer> payload = from(allocator.fromAscii("hello ")).concat(who);
    // Wrap content Publisher to capture its generic type (i.e. Buffer) so it is handled correctly
    final GenericEntity<Publisher<Buffer>> entity = new GenericEntity<Publisher<Buffer>>(payload) {
    };
    return ok(entity).build();
}
Also used : CompositeBuffer(io.servicetalk.buffer.api.CompositeBuffer) Buffer(io.servicetalk.buffer.api.Buffer) GenericEntity(javax.ws.rs.core.GenericEntity) Publisher(io.servicetalk.concurrent.api.Publisher) BufferAllocator(io.servicetalk.buffer.api.BufferAllocator) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 8 with Publisher

use of io.servicetalk.concurrent.api.Publisher in project servicetalk by apple.

the class DefaultDnsClient method dnsSrvQuery.

@Override
public Publisher<Collection<ServiceDiscovererEvent<InetSocketAddress>>> dnsSrvQuery(final String serviceName) {
    requireNonNull(serviceName);
    return defer(() -> {
        // State per subscribe requires defer so each subscribe gets independent state.
        final Map<String, ARecordPublisher> aRecordMap = new HashMap<>(8);
        final Map<InetSocketAddress, Integer> availableAddresses = srvFilterDuplicateEvents ? new HashMap<>(8) : emptyMap();
        final DnsDiscoveryObserver discoveryObserver = newDiscoveryObserver(serviceName);
        // inactive events if necessary.
        return recoverWithInactiveEvents(new SrvRecordPublisher(serviceName, discoveryObserver), true).flatMapConcatIterable(identity()).flatMapMerge(srvEvent -> {
            assertInEventloop();
            if (AVAILABLE.equals(srvEvent.status())) {
                return defer(() -> {
                    final ARecordPublisher aPublisher = new ARecordPublisher(srvEvent.address().hostName(), discoveryObserver);
                    final ARecordPublisher prevAPublisher = aRecordMap.putIfAbsent(srvEvent.address().hostName(), aPublisher);
                    if (prevAPublisher != null) {
                        return newDuplicateSrv(serviceName, srvEvent.address().hostName());
                    }
                    Publisher<? extends Collection<ServiceDiscovererEvent<InetAddress>>> returnPub = recoverWithInactiveEvents(aPublisher, false);
                    return srvFilterDuplicateEvents ? srvFilterDups(returnPub, availableAddresses, srvEvent.address().port()) : returnPub.map(events -> mapEventList(events, inetAddress -> new InetSocketAddress(inetAddress, srvEvent.address().port())));
                }).retryWhen((i, cause) -> {
                    assertInEventloop();
                    // don't retry. Otherwise this is a resolution exception (e.g. UnknownHostException), and retry.
                    return cause == SrvAddressRemovedException.DNS_SRV_ADDR_REMOVED || aRecordMap.remove(srvEvent.address().hostName()) == null ? Completable.failed(cause) : srvHostNameRepeater.apply(i);
                }).onErrorComplete();
            } else if (srvEvent instanceof SrvInactiveEvent) {
                // Unwrap the list so we can use it in SrvInactiveCombinerOperator below.
                return from(((SrvInactiveEvent<HostAndPort, InetSocketAddress>) srvEvent).aggregatedEvents);
            } else {
                final ARecordPublisher aPublisher = aRecordMap.remove(srvEvent.address().hostName());
                if (aPublisher != null) {
                    aPublisher.cancelAndFail0(SrvAddressRemovedException.DNS_SRV_ADDR_REMOVED);
                }
                return empty();
            }
        }, srvConcurrency).liftSync(inactiveEventsOnError ? SrvInactiveCombinerOperator.EMIT : SrvInactiveCombinerOperator.NO_EMIT);
    });
}
Also used : EventLoopAwareNettyIoExecutor(io.servicetalk.transport.netty.internal.EventLoopAwareNettyIoExecutor) CancelImmediatelySubscriber(io.servicetalk.concurrent.internal.CancelImmediatelySubscriber) LoggerFactory(org.slf4j.LoggerFactory) ServiceDiscovererEvent(io.servicetalk.client.api.ServiceDiscovererEvent) Publisher.empty(io.servicetalk.concurrent.api.Publisher.empty) DefaultDnsQuestion(io.netty.handler.codec.dns.DefaultDnsQuestion) DefaultDnsCache(io.netty.resolver.dns.DefaultDnsCache) Collections.singletonList(java.util.Collections.singletonList) InetAddress(java.net.InetAddress) ThrowableUtils.addSuppressed(io.servicetalk.utils.internal.ThrowableUtils.addSuppressed) SubscriberUtils.newExceptionForInvalidRequestN(io.servicetalk.concurrent.internal.SubscriberUtils.newExceptionForInvalidRequestN) Duration(java.time.Duration) Map(java.util.Map) DnsClients.mapEventList(io.servicetalk.dns.discovery.netty.DnsClients.mapEventList) BuilderUtils.socketChannel(io.servicetalk.transport.netty.internal.BuilderUtils.socketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) DnsDiscoveryObserver(io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.DnsDiscoveryObserver) DefaultDnsRecordDecoder.decodeName(io.netty.handler.codec.dns.DefaultDnsRecordDecoder.decodeName) DnsNameResolver(io.netty.resolver.dns.DnsNameResolver) FutureListener(io.netty.util.concurrent.FutureListener) SubscriberUtils.handleExceptionFromOnSubscribe(io.servicetalk.concurrent.internal.SubscriberUtils.handleExceptionFromOnSubscribe) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) ThrowableUtils.unknownStackTrace(io.servicetalk.concurrent.internal.ThrowableUtils.unknownStackTrace) DefaultServiceDiscovererEvent(io.servicetalk.client.api.DefaultServiceDiscovererEvent) EventLoop(io.netty.channel.EventLoop) InetSocketAddress(java.net.InetSocketAddress) List(java.util.List) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) DuplicateSubscribeException(io.servicetalk.concurrent.internal.DuplicateSubscribeException) Function.identity(java.util.function.Function.identity) ResolutionResult(io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.ResolutionResult) DnsRecord(io.netty.handler.codec.dns.DnsRecord) DnsNameResolverBuilder(io.netty.resolver.dns.DnsNameResolverBuilder) Publisher(io.servicetalk.concurrent.api.Publisher) NANOSECONDS(java.util.concurrent.TimeUnit.NANOSECONDS) ByteBuffer.wrap(java.nio.ByteBuffer.wrap) DnsRawRecord(io.netty.handler.codec.dns.DnsRawRecord) HashMap(java.util.HashMap) Cancellable(io.servicetalk.concurrent.Cancellable) DnsResolutionObserver(io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.DnsResolutionObserver) RepeatStrategies.repeatWithConstantBackoffDeltaJitter(io.servicetalk.concurrent.api.RepeatStrategies.repeatWithConstantBackoffDeltaJitter) Subscriber(io.servicetalk.concurrent.PublisherSource.Subscriber) ArrayList(java.util.ArrayList) RandomAccess(java.util.RandomAccess) BuilderUtils.datagramChannel(io.servicetalk.transport.netty.internal.BuilderUtils.datagramChannel) SubscribablePublisher(io.servicetalk.concurrent.api.internal.SubscribablePublisher) AVAILABLE(io.servicetalk.client.api.ServiceDiscovererEvent.Status.AVAILABLE) ByteBuf(io.netty.buffer.ByteBuf) ImmediateEventExecutor(io.netty.util.concurrent.ImmediateEventExecutor) SubscriberUtils.deliverErrorFromSource(io.servicetalk.concurrent.internal.SubscriberUtils.deliverErrorFromSource) ServiceDiscovererUtils.calculateDifference(io.servicetalk.dns.discovery.netty.ServiceDiscovererUtils.calculateDifference) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) SRV(io.netty.handler.codec.dns.DnsRecordType.SRV) Objects.requireNonNull(java.util.Objects.requireNonNull) Comparator.comparing(java.util.Comparator.comparing) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) Publisher.defer(io.servicetalk.concurrent.api.Publisher.defer) SubscriberUtils.safeOnError(io.servicetalk.concurrent.internal.SubscriberUtils.safeOnError) Nullable(javax.annotation.Nullable) IntFunction(java.util.function.IntFunction) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) SubscriberUtils.isRequestNValid(io.servicetalk.concurrent.internal.SubscriberUtils.isRequestNValid) Promise(io.netty.util.concurrent.Promise) EventLoopAwareNettyIoExecutors.toEventLoopAwareNettyIoExecutor(io.servicetalk.transport.netty.internal.EventLoopAwareNettyIoExecutors.toEventLoopAwareNettyIoExecutor) ListenableAsyncCloseable(io.servicetalk.concurrent.api.ListenableAsyncCloseable) ClosedChannelException(java.nio.channels.ClosedChannelException) FlowControlUtils.addWithOverflowProtection(io.servicetalk.concurrent.internal.FlowControlUtils.addWithOverflowProtection) Completable(io.servicetalk.concurrent.api.Completable) PublisherOperator(io.servicetalk.concurrent.api.PublisherOperator) AsyncCloseables.toAsyncCloseable(io.servicetalk.concurrent.api.AsyncCloseables.toAsyncCloseable) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) RejectedSubscribeError(io.servicetalk.concurrent.internal.RejectedSubscribeError) IoExecutor(io.servicetalk.transport.api.IoExecutor) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) Completable.completed(io.servicetalk.concurrent.api.Completable.completed) ResolvedAddressTypes(io.netty.resolver.ResolvedAddressTypes) Future(io.netty.util.concurrent.Future) Comparator(java.util.Comparator) SECONDS(java.util.concurrent.TimeUnit.SECONDS) HostAndPort(io.servicetalk.transport.api.HostAndPort) DnsDiscoveryObserver(io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.DnsDiscoveryObserver) HashMap(java.util.HashMap) InetSocketAddress(java.net.InetSocketAddress) Publisher(io.servicetalk.concurrent.api.Publisher) SubscribablePublisher(io.servicetalk.concurrent.api.internal.SubscribablePublisher) HostAndPort(io.servicetalk.transport.api.HostAndPort) Collection(java.util.Collection) InetAddress(java.net.InetAddress)

Example 9 with Publisher

use of io.servicetalk.concurrent.api.Publisher in project servicetalk by apple.

the class ProtobufSerializerMessageBodyReaderWriter method writeTo.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void writeTo(final Object o, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws WebApplicationException {
    final BufferAllocator allocator = ctxRefProvider.get().get().executionContext().bufferAllocator();
    final Publisher<Buffer> bufferPublisher;
    if (o instanceof Single) {
        final Class<? extends MessageLite> clazz = genericType instanceof Class ? (Class) genericType : getSourceClass(genericType);
        Serializer serializer = getSerializerFactory(mediaType).serializerDeserializer(clazz);
        bufferPublisher = ((Single) o).map(t -> serializer.serialize(t, allocator)).toPublisher();
    } else if (o instanceof Publisher) {
        final Class<? extends MessageLite> clazz = genericType instanceof Class ? (Class) genericType : getSourceClass(genericType);
        StreamingSerializer serializer = getSerializerFactory(mediaType).streamingSerializerDeserializer(clazz);
        bufferPublisher = serializer.serialize((Publisher) o, allocator);
    } else {
        Serializer serializer = getSerializerFactory(mediaType).serializerDeserializer((Class<? extends MessageLite>) o.getClass());
        bufferPublisher = Publisher.from(serializer.serialize(o, allocator));
    }
    setResponseBufferPublisher(bufferPublisher, requestCtxProvider.get());
}
Also used : Buffer(io.servicetalk.buffer.api.Buffer) Single(io.servicetalk.concurrent.api.Single) Publisher(io.servicetalk.concurrent.api.Publisher) RequestProperties.setResponseBufferPublisher(io.servicetalk.http.router.jersey.internal.RequestProperties.setResponseBufferPublisher) StreamingSerializer(io.servicetalk.serializer.api.StreamingSerializer) MessageLite(com.google.protobuf.MessageLite) BufferAllocator(io.servicetalk.buffer.api.BufferAllocator) Serializer(io.servicetalk.serializer.api.Serializer) StreamingSerializer(io.servicetalk.serializer.api.StreamingSerializer)

Example 10 with Publisher

use of io.servicetalk.concurrent.api.Publisher in project servicetalk by apple.

the class BlockingStreamingToStreamingService method handle.

@Override
public Single<StreamingHttpResponse> handle(final HttpServiceContext ctx, final StreamingHttpRequest request, final StreamingHttpResponseFactory responseFactory) {
    return new Single<StreamingHttpResponse>() {

        @Override
        protected void handleSubscribe(final Subscriber<? super StreamingHttpResponse> subscriber) {
            final ThreadInterruptingCancellable tiCancellable = new ThreadInterruptingCancellable(currentThread());
            try {
                subscriber.onSubscribe(tiCancellable);
            } catch (Throwable cause) {
                handleExceptionFromOnSubscribe(subscriber, cause);
                return;
            }
            // This exists to help users with error propagation. If the user closes the payloadWriter and they throw
            // (e.g. try-with-resources) this processor is merged with the payloadWriter Publisher so the error will
            // still be propagated.
            final Processor exceptionProcessor = newCompletableProcessor();
            final BufferHttpPayloadWriter payloadWriter = new BufferHttpPayloadWriter(ctx.headersFactory().newTrailers());
            DefaultBlockingStreamingHttpServerResponse response = null;
            try {
                final Consumer<DefaultHttpResponseMetaData> sendMeta = (metaData) -> {
                    final DefaultStreamingHttpResponse result;
                    try {
                        // transfer-encoding takes precedence over content-length.
                        // > When a message does not have a Transfer-Encoding header field, a
                        // Content-Length header field can provide the anticipated size.
                        // https://tools.ietf.org/html/rfc7230#section-3.3.2
                        final HttpHeaders headers = metaData.headers();
                        final HttpProtocolVersion version = metaData.version();
                        boolean addTrailers = version.major() > 1 || isTransferEncodingChunked(headers);
                        if (!addTrailers && h1TrailersSupported(version) && !hasContentLength(headers) && // breaks our HttpResponseDecoder
                        !HEAD.equals(request.method())) {
                            // this is likely not supported in http/1.0 and it is possible that a response has
                            // neither header and the connection close indicates the end of the response.
                            // https://tools.ietf.org/html/rfc7230#section-3.3.3
                            headers.add(TRANSFER_ENCODING, CHUNKED);
                            addTrailers = true;
                        }
                        Publisher<Object> messageBody = fromSource(exceptionProcessor).merge(payloadWriter.connect());
                        if (addTrailers) {
                            messageBody = messageBody.concat(succeeded(payloadWriter.trailers()));
                        }
                        messageBody = messageBody.beforeSubscription(() -> new Subscription() {

                            @Override
                            public void request(final long n) {
                            }

                            @Override
                            public void cancel() {
                                tiCancellable.cancel();
                            }
                        });
                        result = new DefaultStreamingHttpResponse(metaData.status(), version, headers, metaData.context0(), ctx.executionContext().bufferAllocator(), messageBody, forTransportReceive(false, version, headers), ctx.headersFactory());
                    } catch (Throwable t) {
                        subscriber.onError(t);
                        throw t;
                    }
                    subscriber.onSuccess(result);
                };
                response = new DefaultBlockingStreamingHttpServerResponse(OK, request.version(), ctx.headersFactory().newHeaders(), payloadWriter, ctx.executionContext().bufferAllocator(), sendMeta);
                original.handle(ctx, request.toBlockingStreamingRequest(), response);
                // The user code has returned successfully, complete the processor so the response stream can
                // complete. If the user handles the request asynchronously (e.g. on another thread) they are
                // responsible for closing the payloadWriter.
                exceptionProcessor.onComplete();
            } catch (Throwable cause) {
                tiCancellable.setDone(cause);
                if (response == null || response.markMetaSent()) {
                    safeOnError(subscriber, cause);
                } else {
                    try {
                        exceptionProcessor.onError(cause);
                    } finally {
                        safeClose(payloadWriter, cause);
                    }
                }
                return;
            }
            tiCancellable.setDone();
        }
    };
}
Also used : HttpProtocolVersion.h1TrailersSupported(io.servicetalk.http.api.HttpProtocolVersion.h1TrailersSupported) DefaultPayloadInfo.forTransportReceive(io.servicetalk.http.api.DefaultPayloadInfo.forTransportReceive) Publisher(io.servicetalk.concurrent.api.Publisher) Subscriber(io.servicetalk.concurrent.SingleSource.Subscriber) ConnectablePayloadWriter(io.servicetalk.concurrent.api.internal.ConnectablePayloadWriter) PayloadWriterUtils.safeClose(io.servicetalk.oio.api.internal.PayloadWriterUtils.safeClose) Thread.currentThread(java.lang.Thread.currentThread) ThreadInterruptingCancellable(io.servicetalk.concurrent.internal.ThreadInterruptingCancellable) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) HeaderUtils.isTransferEncodingChunked(io.servicetalk.http.api.HeaderUtils.isTransferEncodingChunked) HttpExecutionStrategies.defaultStrategy(io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy) HEAD(io.servicetalk.http.api.HttpRequestMethod.HEAD) Objects.requireNonNull(java.util.Objects.requireNonNull) SubscriberUtils.safeOnError(io.servicetalk.concurrent.internal.SubscriberUtils.safeOnError) Processors.newCompletableProcessor(io.servicetalk.concurrent.api.Processors.newCompletableProcessor) CHUNKED(io.servicetalk.http.api.HttpHeaderValues.CHUNKED) SubscriberUtils.handleExceptionFromOnSubscribe(io.servicetalk.concurrent.internal.SubscriberUtils.handleExceptionFromOnSubscribe) Single(io.servicetalk.concurrent.api.Single) Completable(io.servicetalk.concurrent.api.Completable) OFFLOAD_RECEIVE_META_STRATEGY(io.servicetalk.http.api.DefaultHttpExecutionStrategy.OFFLOAD_RECEIVE_META_STRATEGY) TRANSFER_ENCODING(io.servicetalk.http.api.HttpHeaderNames.TRANSFER_ENCODING) IOException(java.io.IOException) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) OK(io.servicetalk.http.api.HttpResponseStatus.OK) Consumer(java.util.function.Consumer) HeaderUtils.hasContentLength(io.servicetalk.http.api.HeaderUtils.hasContentLength) Buffer(io.servicetalk.buffer.api.Buffer) Processor(io.servicetalk.concurrent.CompletableSource.Processor) Processors.newCompletableProcessor(io.servicetalk.concurrent.api.Processors.newCompletableProcessor) Processor(io.servicetalk.concurrent.CompletableSource.Processor) ThreadInterruptingCancellable(io.servicetalk.concurrent.internal.ThreadInterruptingCancellable) Publisher(io.servicetalk.concurrent.api.Publisher) Single(io.servicetalk.concurrent.api.Single) Subscriber(io.servicetalk.concurrent.SingleSource.Subscriber) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription)

Aggregations

Publisher (io.servicetalk.concurrent.api.Publisher)30 Buffer (io.servicetalk.buffer.api.Buffer)16 Single (io.servicetalk.concurrent.api.Single)15 Test (org.junit.jupiter.api.Test)15 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)13 Completable (io.servicetalk.concurrent.api.Completable)12 PublisherSource (io.servicetalk.concurrent.PublisherSource)11 Collection (java.util.Collection)11 SourceAdapters.toSource (io.servicetalk.concurrent.api.SourceAdapters.toSource)10 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)10 ArrayList (java.util.ArrayList)10 List (java.util.List)10 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)10 Matchers.is (org.hamcrest.Matchers.is)10 Subscription (io.servicetalk.concurrent.PublisherSource.Subscription)9 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)9 DEFAULT_ALLOCATOR (io.servicetalk.buffer.netty.BufferAllocators.DEFAULT_ALLOCATOR)8 Completable.completed (io.servicetalk.concurrent.api.Completable.completed)8 Executor (io.servicetalk.concurrent.api.Executor)8 HttpHeaders (io.servicetalk.http.api.HttpHeaders)8