Search in sources :

Example 1 with StreamedHttpResponse

use of io.micronaut.http.netty.stream.StreamedHttpResponse in project micronaut-core by micronaut-projects.

the class DefaultHttpClient method buildExchangeStreamPublisher.

/**
 * @param request   The request
 * @param errorType The error type
 * @param <I>       The input type
 * @return A {@link Function}
 */
protected <I> Function<URI, Publisher<HttpResponse<ByteBuffer<?>>>> buildExchangeStreamPublisher(@NonNull io.micronaut.http.HttpRequest<I> request, @NonNull Argument<?> errorType) {
    final io.micronaut.http.HttpRequest<Object> parentRequest = ServerRequestContext.currentRequest().orElse(null);
    return requestURI -> {
        Flux<io.micronaut.http.HttpResponse<Object>> streamResponsePublisher = Flux.from(buildStreamExchange(parentRequest, request, requestURI, errorType));
        return streamResponsePublisher.switchMap(response -> {
            StreamedHttpResponse streamedHttpResponse = NettyHttpResponseBuilder.toStreamResponse(response);
            Flux<HttpContent> httpContentReactiveSequence = Flux.from(streamedHttpResponse);
            return httpContentReactiveSequence.filter(message -> !(message.content() instanceof EmptyByteBuf)).map(message -> {
                ByteBuf byteBuf = message.content();
                if (log.isTraceEnabled()) {
                    log.trace("HTTP Client Streaming Response Received Chunk (length: {}) for Request: {} {}", byteBuf.readableBytes(), request.getMethodName(), request.getUri());
                    traceBody("Response", byteBuf);
                }
                ByteBuffer<?> byteBuffer = byteBufferFactory.wrap(byteBuf);
                NettyStreamedHttpResponse<ByteBuffer<?>> thisResponse = new NettyStreamedHttpResponse<>(streamedHttpResponse, response.status());
                thisResponse.setBody(byteBuffer);
                return (HttpResponse<ByteBuffer<?>>) new HttpResponseWrapper<>(thisResponse);
            });
        }).doOnTerminate(() -> {
            final Object o = request.getAttribute(NettyClientHttpRequest.CHANNEL).orElse(null);
            if (o instanceof Channel) {
                final Channel c = (Channel) o;
                if (c.isOpen()) {
                    c.close();
                }
            }
        });
    };
}
Also used : AttributeKey(io.netty.util.AttributeKey) OrderUtil(io.micronaut.core.order.OrderUtil) Publishers(io.micronaut.core.async.publisher.Publishers) NoHostException(io.micronaut.http.client.exceptions.NoHostException) Processor(org.reactivestreams.Processor) JacksonDatabindMapper(io.micronaut.jackson.databind.JacksonDatabindMapper) ProxyHttpClient(io.micronaut.http.client.ProxyHttpClient) HttpProxyHandler(io.netty.handler.proxy.HttpProxyHandler) SseClient(io.micronaut.http.client.sse.SseClient) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) HANDLER_IDLE_STATE(io.micronaut.http.netty.channel.ChannelPipelineCustomizer.HANDLER_IDLE_STATE) Internal(io.micronaut.core.annotation.Internal) NettyClientSslBuilder(io.micronaut.http.client.netty.ssl.NettyClientSslBuilder) Proxy(java.net.Proxy) InstantiationUtils(io.micronaut.core.reflect.InstantiationUtils) HttpStatus(io.micronaut.http.HttpStatus) Duration(java.time.Duration) CharsetUtil(io.netty.util.CharsetUtil) HANDLER_HTTP2_SETTINGS(io.micronaut.http.netty.channel.ChannelPipelineCustomizer.HANDLER_HTTP2_SETTINGS) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) ArgumentUtils(io.micronaut.core.util.ArgumentUtils) WebSocketClientHandshakerFactory(io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory) MapperMediaTypeCodec(io.micronaut.json.codec.MapperMediaTypeCodec) LoadBalancer(io.micronaut.http.client.LoadBalancer) SocketChannel(io.netty.channel.socket.SocketChannel) HttpClientErrorDecoder(io.micronaut.http.client.exceptions.HttpClientErrorDecoder) ResourceResolver(io.micronaut.core.io.ResourceResolver) ByteBufferFactory(io.micronaut.core.io.buffer.ByteBufferFactory) ReadTimeoutException(io.micronaut.http.client.exceptions.ReadTimeoutException) IdleStateEvent(io.netty.handler.timeout.IdleStateEvent) ChannelHealthChecker(io.netty.channel.pool.ChannelHealthChecker) StreamingInboundHttp2ToHttpAdapter(io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter) StandardCharsets(java.nio.charset.StandardCharsets) HttpFilterResolver(io.micronaut.http.filter.HttpFilterResolver) ClientFilterResolutionContext(io.micronaut.http.client.filter.ClientFilterResolutionContext) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) AbstractChannelPoolHandler(io.netty.channel.pool.AbstractChannelPoolHandler) SslHandler(io.netty.handler.ssl.SslHandler) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) MutableHttpRequest(io.micronaut.http.MutableHttpRequest) NettyWebSocketClientHandler(io.micronaut.http.client.netty.websocket.NettyWebSocketClientHandler) ChannelPoolMap(io.netty.channel.pool.ChannelPoolMap) MultipartDataFactory(io.micronaut.http.client.multipart.MultipartDataFactory) NettyByteBufferFactory(io.micronaut.buffer.netty.NettyByteBufferFactory) java.util(java.util) Disposable(reactor.core.Disposable) WebSocketBean(io.micronaut.websocket.context.WebSocketBean) OnMessage(io.micronaut.websocket.annotation.OnMessage) ContentLengthExceededException(io.micronaut.http.client.exceptions.ContentLengthExceededException) Supplier(java.util.function.Supplier) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) NettyThreadFactory(io.micronaut.http.netty.channel.NettyThreadFactory) NettyHttpRequestBuilder(io.micronaut.http.netty.NettyHttpRequestBuilder) DefaultHttpClientConfiguration(io.micronaut.http.client.DefaultHttpClientConfiguration) NettyHttpHeaders(io.micronaut.http.netty.NettyHttpHeaders) Nullable(io.micronaut.core.annotation.Nullable) ByteBuffer(io.micronaut.core.io.buffer.ByteBuffer) JsonStreamMediaTypeCodec(io.micronaut.json.codec.JsonStreamMediaTypeCodec) Argument(io.micronaut.core.type.Argument) MultipartException(io.micronaut.http.multipart.MultipartException) ConversionService(io.micronaut.core.convert.ConversionService) ServerRequestContext(io.micronaut.http.context.ServerRequestContext) NOOP(io.micronaut.scheduling.instrument.InvocationInstrumenter.NOOP) MediaTypeCodecRegistry(io.micronaut.http.codec.MediaTypeCodecRegistry) Attribute(io.netty.util.Attribute) JsonNode(io.micronaut.json.tree.JsonNode) SslContext(io.netty.handler.ssl.SslContext) FileUpload(io.netty.handler.codec.http.multipart.FileUpload) Publisher(org.reactivestreams.Publisher) HttpClientConfiguration(io.micronaut.http.client.HttpClientConfiguration) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) NettyHttpResponseBuilder(io.micronaut.http.netty.NettyHttpResponseBuilder) File(java.io.File) AbstractNettyHttpRequest(io.micronaut.http.netty.AbstractNettyHttpRequest) SimpleChannelPool(io.netty.channel.pool.SimpleChannelPool) Bootstrap(io.netty.bootstrap.Bootstrap) Flux(reactor.core.publisher.Flux) WebSocketClientCompressionHandler(io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler) DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS(io.micronaut.http.client.HttpClientConfiguration.DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS) ChannelPipelineCustomizer(io.micronaut.http.netty.channel.ChannelPipelineCustomizer) ChannelPool(io.netty.channel.pool.ChannelPool) Instrumentation(io.micronaut.scheduling.instrument.Instrumentation) WebSocketClient(io.micronaut.websocket.WebSocketClient) Future(io.netty.util.concurrent.Future) DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) ChannelPipelineListener(io.micronaut.http.netty.channel.ChannelPipelineListener) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) SocketAddress(java.net.SocketAddress) HttpStreamsClientHandler(io.micronaut.http.netty.stream.HttpStreamsClientHandler) UriTemplate(io.micronaut.http.uri.UriTemplate) io.netty.handler.codec.http2(io.netty.handler.codec.http2) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) DEFAULT_SHUTDOWN_QUIET_PERIOD_MILLISECONDS(io.micronaut.http.client.HttpClientConfiguration.DEFAULT_SHUTDOWN_QUIET_PERIOD_MILLISECONDS) ArrayUtils(io.micronaut.core.util.ArrayUtils) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) InvocationInstrumenter(io.micronaut.scheduling.instrument.InvocationInstrumenter) InvocationInstrumenterFactory(io.micronaut.scheduling.instrument.InvocationInstrumenterFactory) ClientFilterChain(io.micronaut.http.filter.ClientFilterChain) DefaultHttp2Content(io.micronaut.http.netty.stream.DefaultHttp2Content) Event(io.micronaut.http.sse.Event) Unpooled(io.netty.buffer.Unpooled) FixedChannelPool(io.netty.channel.pool.FixedChannelPool) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MediaType(io.micronaut.http.MediaType) ReferenceCounted(io.micronaut.core.io.buffer.ReferenceCounted) JsonMapper(io.micronaut.json.JsonMapper) ApplicationProtocolNegotiationHandler(io.netty.handler.ssl.ApplicationProtocolNegotiationHandler) HttpResponse(io.micronaut.http.HttpResponse) ApplicationConfiguration(io.micronaut.runtime.ApplicationConfiguration) URI(java.net.URI) HttpClient(io.micronaut.http.client.HttpClient) HttpDataFactory(io.netty.handler.codec.http.multipart.HttpDataFactory) ThreadFactory(java.util.concurrent.ThreadFactory) RequestBinderRegistry(io.micronaut.http.bind.RequestBinderRegistry) MultipartBody(io.micronaut.http.client.multipart.MultipartBody) JsonMediaTypeCodec(io.micronaut.json.codec.JsonMediaTypeCodec) CodecException(io.micronaut.http.codec.CodecException) ReadTimeoutHandler(io.netty.handler.timeout.ReadTimeoutHandler) MutableHttpResponse(io.micronaut.http.MutableHttpResponse) MutableHttpHeaders(io.micronaut.http.MutableHttpHeaders) TooLongFrameException(io.netty.handler.codec.TooLongFrameException) InterfaceHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) StringUtils(io.micronaut.core.util.StringUtils) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) HttpClientFilter(io.micronaut.http.filter.HttpClientFilter) StreamedHttpRequest(io.micronaut.http.netty.stream.StreamedHttpRequest) io.netty.handler.codec.http(io.netty.handler.codec.http) StreamingHttpClient(io.micronaut.http.client.StreamingHttpClient) WebSocketSessionException(io.micronaut.websocket.exceptions.WebSocketSessionException) Type(java.net.Proxy.Type) Socks5ProxyHandler(io.netty.handler.proxy.Socks5ProxyHandler) ClientWebSocket(io.micronaut.websocket.annotation.ClientWebSocket) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) ClientServerContextFilter(io.micronaut.http.client.filters.ClientServerContextFilter) LoggingHandler(io.netty.handler.logging.LoggingHandler) UriBuilder(io.micronaut.http.uri.UriBuilder) HttpPostRequestEncoder(io.netty.handler.codec.http.multipart.HttpPostRequestEncoder) FluxSink(reactor.core.publisher.FluxSink) DefaultHttpDataFactory(io.netty.handler.codec.http.multipart.DefaultHttpDataFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HttpClientFilterResolver(io.micronaut.http.filter.HttpClientFilterResolver) Scheduler(reactor.core.scheduler.Scheduler) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) WebSocketBeanRegistry(io.micronaut.websocket.context.WebSocketBeanRegistry) BeanMap(io.micronaut.core.beans.BeanMap) NoopAddressResolverGroup(io.netty.resolver.NoopAddressResolverGroup) WebSocketVersion(io.netty.handler.codec.http.websocketx.WebSocketVersion) BlockingHttpClient(io.micronaut.http.client.BlockingHttpClient) ByteBuf(io.netty.buffer.ByteBuf) Charset(java.nio.charset.Charset) HttpClientException(io.micronaut.http.client.exceptions.HttpClientException) io.netty.channel(io.netty.channel) Schedulers(reactor.core.scheduler.Schedulers) HttpResponseWrapper(io.micronaut.http.HttpResponseWrapper) Subscriber(org.reactivestreams.Subscriber) MediaTypeCodec(io.micronaut.http.codec.MediaTypeCodec) Logger(org.slf4j.Logger) DefaultRequestBinderRegistry(io.micronaut.http.bind.DefaultRequestBinderRegistry) MalformedURLException(java.net.MalformedURLException) AnnotationMetadataResolver(io.micronaut.core.annotation.AnnotationMetadataResolver) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) ApplicationProtocolNames(io.netty.handler.ssl.ApplicationProtocolNames) DefaultHttpClientFilterResolver(io.micronaut.http.client.filter.DefaultHttpClientFilterResolver) Http2Content(io.micronaut.http.netty.stream.Http2Content) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NonNull(io.micronaut.core.annotation.NonNull) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) ByteBufUtil(io.netty.buffer.ByteBufUtil) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) CollectionUtils(io.micronaut.core.util.CollectionUtils) Subscription(org.reactivestreams.Subscription) Closeable(java.io.Closeable) AnnotationMetadata(io.micronaut.core.annotation.AnnotationMetadata) AbstractChannelPoolMap(io.netty.channel.pool.AbstractChannelPoolMap) JsonSubscriber(io.micronaut.http.netty.stream.JsonSubscriber) InputStream(java.io.InputStream) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) SocketChannel(io.netty.channel.socket.SocketChannel) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Flux(reactor.core.publisher.Flux) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) HttpResponse(io.micronaut.http.HttpResponse) MutableHttpResponse(io.micronaut.http.MutableHttpResponse) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) ByteBuf(io.netty.buffer.ByteBuf) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) ByteBuffer(io.micronaut.core.io.buffer.ByteBuffer) io.netty.handler.codec.http(io.netty.handler.codec.http)

Example 2 with StreamedHttpResponse

use of io.micronaut.http.netty.stream.StreamedHttpResponse in project micronaut-core by micronaut-projects.

the class DefaultHttpClient method readBodyOnError.

private Flux<io.micronaut.http.HttpResponse<Object>> readBodyOnError(@NonNull Argument<?> errorType, @NonNull Flux<io.micronaut.http.HttpResponse<Object>> publisher) {
    if (errorType != null && errorType != HttpClient.DEFAULT_ERROR_TYPE) {
        return publisher.onErrorResume(clientException -> {
            if (clientException instanceof HttpClientResponseException) {
                final HttpResponse<?> response = ((HttpClientResponseException) clientException).getResponse();
                if (response instanceof NettyStreamedHttpResponse) {
                    return Mono.create(emitter -> {
                        NettyStreamedHttpResponse<?> streamedResponse = (NettyStreamedHttpResponse<?>) response;
                        final StreamedHttpResponse nettyResponse = streamedResponse.getNettyResponse();
                        nettyResponse.subscribe(new Subscriber<HttpContent>() {

                            final CompositeByteBuf buffer = byteBufferFactory.getNativeAllocator().compositeBuffer();

                            Subscription s;

                            @Override
                            public void onSubscribe(Subscription s) {
                                this.s = s;
                                s.request(1);
                            }

                            @Override
                            public void onNext(HttpContent httpContent) {
                                buffer.addComponent(true, httpContent.content());
                                s.request(1);
                            }

                            @Override
                            public void onError(Throwable t) {
                                buffer.release();
                                emitter.error(t);
                            }

                            @Override
                            public void onComplete() {
                                try {
                                    FullHttpResponse fullHttpResponse = new DefaultFullHttpResponse(nettyResponse.protocolVersion(), nettyResponse.status(), buffer, nettyResponse.headers(), new DefaultHttpHeaders(true));
                                    final FullNettyClientHttpResponse<Object> fullNettyClientHttpResponse = new FullNettyClientHttpResponse<>(fullHttpResponse, response.status(), mediaTypeCodecRegistry, byteBufferFactory, (Argument<Object>) errorType, true);
                                    fullNettyClientHttpResponse.onComplete();
                                    emitter.error(new HttpClientResponseException(fullHttpResponse.status().reasonPhrase(), null, fullNettyClientHttpResponse, new HttpClientErrorDecoder() {

                                        @Override
                                        public Argument<?> getErrorType(MediaType mediaType) {
                                            return errorType;
                                        }
                                    }));
                                } finally {
                                    buffer.release();
                                }
                            }
                        });
                    });
                }
            }
            return Mono.error(clientException);
        });
    }
    return publisher;
}
Also used : StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) Argument(io.micronaut.core.type.Argument) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) HttpClientErrorDecoder(io.micronaut.http.client.exceptions.HttpClientErrorDecoder) MediaType(io.micronaut.http.MediaType) Subscription(org.reactivestreams.Subscription)

Example 3 with StreamedHttpResponse

use of io.micronaut.http.netty.stream.StreamedHttpResponse in project micronaut-core by micronaut-projects.

the class DefaultHttpClient method streamRequestThroughChannel.

private void streamRequestThroughChannel(io.micronaut.http.HttpRequest<?> parentRequest, AtomicReference<io.micronaut.http.HttpRequest> requestWrapper, FluxSink emitter, Channel channel, boolean failOnError) throws HttpPostRequestEncoder.ErrorDataEncoderException {
    io.micronaut.http.HttpRequest<?> finalRequest = requestWrapper.get();
    URI requestURI = finalRequest.getUri();
    NettyRequestWriter requestWriter = prepareRequest(finalRequest, requestURI, emitter, false);
    HttpRequest nettyRequest = requestWriter.getNettyRequest();
    ChannelPipeline pipeline = channel.pipeline();
    pipeline.addLast(ChannelPipelineCustomizer.HANDLER_MICRONAUT_HTTP_RESPONSE_FULL, new SimpleChannelInboundHandlerInstrumented<FullHttpResponse>() {

        final AtomicBoolean received = new AtomicBoolean(false);

        @Override
        public boolean acceptInboundMessage(Object msg) {
            return msg instanceof FullHttpResponse;
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
            if (received.compareAndSet(false, true)) {
                emitter.error(cause);
            }
        }

        @Override
        public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
            if (evt instanceof IdleStateEvent && received.compareAndSet(false, true)) {
                // closed to idle ste
                emitter.error(ReadTimeoutException.TIMEOUT_EXCEPTION);
            }
        }

        @Override
        protected void channelReadInstrumented(ChannelHandlerContext ctx, FullHttpResponse msg) {
            if (received.compareAndSet(false, true)) {
                HttpResponseStatus status = msg.status();
                int statusCode = status.code();
                HttpStatus httpStatus;
                try {
                    httpStatus = HttpStatus.valueOf(statusCode);
                } catch (IllegalArgumentException e) {
                    emitter.error(e);
                    return;
                }
                Publisher<HttpContent> bodyPublisher;
                if (msg.content() instanceof EmptyByteBuf) {
                    bodyPublisher = Publishers.empty();
                } else {
                    bodyPublisher = Publishers.just(new DefaultLastHttpContent(msg.content()));
                }
                DefaultStreamedHttpResponse nettyResponse = new DefaultStreamedHttpResponse(msg.protocolVersion(), msg.status(), msg.headers(), bodyPublisher);
                NettyStreamedHttpResponse response = new NettyStreamedHttpResponse(nettyResponse, httpStatus);
                HttpHeaders headers = msg.headers();
                if (log.isTraceEnabled()) {
                    log.trace("HTTP Client Streaming Response Received ({}) for Request: {} {}", msg.status(), nettyRequest.method().name(), nettyRequest.uri());
                    traceHeaders(headers);
                }
                boolean errorStatus = statusCode >= 400;
                if (errorStatus && failOnError) {
                    emitter.error(new HttpClientResponseException(response.getStatus().getReason(), response));
                } else {
                    emitter.next(response);
                    emitter.complete();
                }
            }
        }
    });
    pipeline.addLast(ChannelPipelineCustomizer.HANDLER_MICRONAUT_HTTP_RESPONSE_STREAM, new SimpleChannelInboundHandlerInstrumented<StreamedHttpResponse>() {

        final AtomicBoolean received = new AtomicBoolean(false);

        @Override
        public boolean acceptInboundMessage(Object msg) {
            return msg instanceof StreamedHttpResponse;
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
            if (received.compareAndSet(false, true)) {
                emitter.error(cause);
            }
        }

        @Override
        protected void channelReadInstrumented(ChannelHandlerContext ctx, StreamedHttpResponse msg) {
            if (received.compareAndSet(false, true)) {
                HttpResponseStatus status = msg.status();
                int statusCode = status.code();
                HttpStatus httpStatus;
                try {
                    httpStatus = HttpStatus.valueOf(statusCode);
                } catch (IllegalArgumentException e) {
                    emitter.error(e);
                    return;
                }
                NettyStreamedHttpResponse response = new NettyStreamedHttpResponse(msg, httpStatus);
                HttpHeaders headers = msg.headers();
                if (log.isTraceEnabled()) {
                    log.trace("HTTP Client Streaming Response Received ({}) for Request: {} {}", msg.status(), nettyRequest.method().name(), nettyRequest.uri());
                    traceHeaders(headers);
                }
                if (statusCode > 300 && statusCode < 400 && configuration.isFollowRedirects() && headers.contains(HttpHeaderNames.LOCATION)) {
                    String location = headers.get(HttpHeaderNames.LOCATION);
                    Flux<io.micronaut.http.HttpResponse<Object>> redirectedExchange;
                    try {
                        MutableHttpRequest<Object> redirectRequest;
                        if (statusCode == 307) {
                            redirectRequest = io.micronaut.http.HttpRequest.create(finalRequest.getMethod(), location);
                            finalRequest.getBody().ifPresent(redirectRequest::body);
                        } else {
                            redirectRequest = io.micronaut.http.HttpRequest.GET(location);
                        }
                        setRedirectHeaders(nettyRequest, redirectRequest);
                        redirectedExchange = Flux.from(resolveRedirectURI(parentRequest, redirectRequest)).flatMap(uri -> buildStreamExchange(parentRequest, redirectRequest, uri, null));
                        // noinspection SubscriberImplementation
                        redirectedExchange.subscribe(new Subscriber<io.micronaut.http.HttpResponse<Object>>() {

                            Subscription sub;

                            @Override
                            public void onSubscribe(Subscription s) {
                                s.request(1);
                                this.sub = s;
                            }

                            @Override
                            public void onNext(io.micronaut.http.HttpResponse<Object> objectHttpResponse) {
                                emitter.next(objectHttpResponse);
                            }

                            @Override
                            public void onError(Throwable t) {
                                emitter.error(t);
                            }

                            @Override
                            public void onComplete() {
                                emitter.complete();
                            }
                        });
                    } catch (Exception e) {
                        emitter.error(e);
                    }
                } else {
                    boolean errorStatus = statusCode >= 400;
                    if (errorStatus && failOnError) {
                        emitter.error(new HttpClientResponseException(response.getStatus().getReason(), response));
                    } else {
                        emitter.next(response);
                        emitter.complete();
                    }
                }
            }
        }
    });
    if (log.isDebugEnabled()) {
        debugRequest(requestURI, nettyRequest);
    }
    if (log.isTraceEnabled()) {
        traceRequest(requestWrapper.get(), nettyRequest);
    }
    requestWriter.writeAndClose(channel, null, emitter);
}
Also used : NettyHttpHeaders(io.micronaut.http.netty.NettyHttpHeaders) MutableHttpHeaders(io.micronaut.http.MutableHttpHeaders) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) URI(java.net.URI) Subscriber(org.reactivestreams.Subscriber) JsonSubscriber(io.micronaut.http.netty.stream.JsonSubscriber) Subscription(org.reactivestreams.Subscription) MutableHttpRequest(io.micronaut.http.MutableHttpRequest) AbstractNettyHttpRequest(io.micronaut.http.netty.AbstractNettyHttpRequest) StreamedHttpRequest(io.micronaut.http.netty.stream.StreamedHttpRequest) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) HttpStatus(io.micronaut.http.HttpStatus) Flux(reactor.core.publisher.Flux) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) HttpResponse(io.micronaut.http.HttpResponse) MutableHttpResponse(io.micronaut.http.MutableHttpResponse) Publisher(org.reactivestreams.Publisher) MutableHttpRequest(io.micronaut.http.MutableHttpRequest) NoHostException(io.micronaut.http.client.exceptions.NoHostException) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) ReadTimeoutException(io.micronaut.http.client.exceptions.ReadTimeoutException) ContentLengthExceededException(io.micronaut.http.client.exceptions.ContentLengthExceededException) MultipartException(io.micronaut.http.multipart.MultipartException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) CodecException(io.micronaut.http.codec.CodecException) TooLongFrameException(io.netty.handler.codec.TooLongFrameException) WebSocketSessionException(io.micronaut.websocket.exceptions.WebSocketSessionException) HttpClientException(io.micronaut.http.client.exceptions.HttpClientException) MalformedURLException(java.net.MalformedURLException) IdleStateEvent(io.netty.handler.timeout.IdleStateEvent) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) io.netty.handler.codec.http(io.netty.handler.codec.http)

Example 4 with StreamedHttpResponse

use of io.micronaut.http.netty.stream.StreamedHttpResponse in project micronaut-core by micronaut-projects.

the class NettyHttpResponseBuilder method toStreamResponse.

/**
 * Convert the given response to a full http response.
 * @param response The response
 * @return The full response.
 */
@NonNull
static StreamedHttpResponse toStreamResponse(@NonNull io.micronaut.http.HttpResponse<?> response) {
    Objects.requireNonNull(response, "The response cannot be null");
    while (response instanceof HttpResponseWrapper) {
        response = ((HttpResponseWrapper<?>) response).getDelegate();
    }
    if (response instanceof NettyHttpResponseBuilder) {
        NettyHttpResponseBuilder builder = (NettyHttpResponseBuilder) response;
        if (builder.isStream()) {
            return builder.toStreamHttpResponse();
        } else {
            FullHttpResponse fullHttpResponse = builder.toFullHttpResponse();
            return new DefaultStreamedHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(response.code(), response.reason()), Publishers.just(new DefaultLastHttpContent(fullHttpResponse.content())));
        }
    }
    // manual conversion
    StreamedHttpResponse fullHttpResponse;
    ByteBuf byteBuf = response.getBody(ByteBuf.class).orElse(null);
    if (byteBuf != null) {
        fullHttpResponse = new DefaultStreamedHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(response.code(), response.reason()), Publishers.just(new DefaultLastHttpContent(byteBuf)));
    } else {
        fullHttpResponse = new DefaultStreamedHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(response.code(), response.reason()), Publishers.empty());
    }
    response.getHeaders().forEach((s, strings) -> fullHttpResponse.headers().add(s, strings));
    return fullHttpResponse;
}
Also used : HttpResponseWrapper(io.micronaut.http.HttpResponseWrapper) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) DefaultLastHttpContent(io.netty.handler.codec.http.DefaultLastHttpContent) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) ByteBuf(io.netty.buffer.ByteBuf) NonNull(io.micronaut.core.annotation.NonNull)

Example 5 with StreamedHttpResponse

use of io.micronaut.http.netty.stream.StreamedHttpResponse in project micronaut-core by micronaut-projects.

the class DefaultHttpClient method buildJsonStreamPublisher.

/**
 * @param parentRequest The parent request
 * @param request       The request
 * @param type          The type
 * @param errorType     The error type
 * @param <I>           The input type
 * @param <O>           The output type
 * @return A {@link Function}
 */
protected <I, O> Function<URI, Publisher<O>> buildJsonStreamPublisher(io.micronaut.http.HttpRequest<?> parentRequest, io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> type, io.micronaut.core.type.Argument<?> errorType) {
    return requestURI -> {
        Flux<io.micronaut.http.HttpResponse<Object>> streamResponsePublisher = Flux.from(buildStreamExchange(parentRequest, request, requestURI, errorType));
        return streamResponsePublisher.switchMap(response -> {
            if (!(response instanceof NettyStreamedHttpResponse)) {
                throw new IllegalStateException("Response has been wrapped in non streaming type. Do not wrap the response in client filters for stream requests");
            }
            MapperMediaTypeCodec mediaTypeCodec = (MapperMediaTypeCodec) mediaTypeCodecRegistry.findCodec(MediaType.APPLICATION_JSON_TYPE).orElseThrow(() -> new IllegalStateException("No JSON codec found"));
            StreamedHttpResponse streamResponse = NettyHttpResponseBuilder.toStreamResponse(response);
            Flux<HttpContent> httpContentReactiveSequence = Flux.from(streamResponse);
            boolean isJsonStream = response.getContentType().map(mediaType -> mediaType.equals(MediaType.APPLICATION_JSON_STREAM_TYPE)).orElse(false);
            boolean streamArray = !Iterable.class.isAssignableFrom(type.getType()) && !isJsonStream;
            Processor<byte[], JsonNode> jsonProcessor = mediaTypeCodec.getJsonMapper().createReactiveParser(p -> {
                httpContentReactiveSequence.map(content -> {
                    ByteBuf chunk = content.content();
                    if (log.isTraceEnabled()) {
                        log.trace("HTTP Client Streaming Response Received Chunk (length: {}) for Request: {} {}", chunk.readableBytes(), request.getMethodName(), request.getUri());
                        traceBody("Chunk", chunk);
                    }
                    try {
                        return ByteBufUtil.getBytes(chunk);
                    } finally {
                        chunk.release();
                    }
                }).subscribe(p);
            }, streamArray);
            return Flux.from(jsonProcessor).map(jsonNode -> mediaTypeCodec.decode(type, jsonNode));
        }).doOnTerminate(() -> {
            final Object o = request.getAttribute(NettyClientHttpRequest.CHANNEL).orElse(null);
            if (o instanceof Channel) {
                final Channel c = (Channel) o;
                if (c.isOpen()) {
                    c.close();
                }
            }
        });
    };
}
Also used : AttributeKey(io.netty.util.AttributeKey) OrderUtil(io.micronaut.core.order.OrderUtil) Publishers(io.micronaut.core.async.publisher.Publishers) NoHostException(io.micronaut.http.client.exceptions.NoHostException) Processor(org.reactivestreams.Processor) JacksonDatabindMapper(io.micronaut.jackson.databind.JacksonDatabindMapper) ProxyHttpClient(io.micronaut.http.client.ProxyHttpClient) HttpProxyHandler(io.netty.handler.proxy.HttpProxyHandler) SseClient(io.micronaut.http.client.sse.SseClient) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) HANDLER_IDLE_STATE(io.micronaut.http.netty.channel.ChannelPipelineCustomizer.HANDLER_IDLE_STATE) Internal(io.micronaut.core.annotation.Internal) NettyClientSslBuilder(io.micronaut.http.client.netty.ssl.NettyClientSslBuilder) Proxy(java.net.Proxy) InstantiationUtils(io.micronaut.core.reflect.InstantiationUtils) HttpStatus(io.micronaut.http.HttpStatus) Duration(java.time.Duration) CharsetUtil(io.netty.util.CharsetUtil) HANDLER_HTTP2_SETTINGS(io.micronaut.http.netty.channel.ChannelPipelineCustomizer.HANDLER_HTTP2_SETTINGS) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) ArgumentUtils(io.micronaut.core.util.ArgumentUtils) WebSocketClientHandshakerFactory(io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory) MapperMediaTypeCodec(io.micronaut.json.codec.MapperMediaTypeCodec) LoadBalancer(io.micronaut.http.client.LoadBalancer) SocketChannel(io.netty.channel.socket.SocketChannel) HttpClientErrorDecoder(io.micronaut.http.client.exceptions.HttpClientErrorDecoder) ResourceResolver(io.micronaut.core.io.ResourceResolver) ByteBufferFactory(io.micronaut.core.io.buffer.ByteBufferFactory) ReadTimeoutException(io.micronaut.http.client.exceptions.ReadTimeoutException) IdleStateEvent(io.netty.handler.timeout.IdleStateEvent) ChannelHealthChecker(io.netty.channel.pool.ChannelHealthChecker) StreamingInboundHttp2ToHttpAdapter(io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter) StandardCharsets(java.nio.charset.StandardCharsets) HttpFilterResolver(io.micronaut.http.filter.HttpFilterResolver) ClientFilterResolutionContext(io.micronaut.http.client.filter.ClientFilterResolutionContext) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) AbstractChannelPoolHandler(io.netty.channel.pool.AbstractChannelPoolHandler) SslHandler(io.netty.handler.ssl.SslHandler) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) MutableHttpRequest(io.micronaut.http.MutableHttpRequest) NettyWebSocketClientHandler(io.micronaut.http.client.netty.websocket.NettyWebSocketClientHandler) ChannelPoolMap(io.netty.channel.pool.ChannelPoolMap) MultipartDataFactory(io.micronaut.http.client.multipart.MultipartDataFactory) NettyByteBufferFactory(io.micronaut.buffer.netty.NettyByteBufferFactory) java.util(java.util) Disposable(reactor.core.Disposable) WebSocketBean(io.micronaut.websocket.context.WebSocketBean) OnMessage(io.micronaut.websocket.annotation.OnMessage) ContentLengthExceededException(io.micronaut.http.client.exceptions.ContentLengthExceededException) Supplier(java.util.function.Supplier) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) NettyThreadFactory(io.micronaut.http.netty.channel.NettyThreadFactory) NettyHttpRequestBuilder(io.micronaut.http.netty.NettyHttpRequestBuilder) DefaultHttpClientConfiguration(io.micronaut.http.client.DefaultHttpClientConfiguration) NettyHttpHeaders(io.micronaut.http.netty.NettyHttpHeaders) Nullable(io.micronaut.core.annotation.Nullable) ByteBuffer(io.micronaut.core.io.buffer.ByteBuffer) JsonStreamMediaTypeCodec(io.micronaut.json.codec.JsonStreamMediaTypeCodec) Argument(io.micronaut.core.type.Argument) MultipartException(io.micronaut.http.multipart.MultipartException) ConversionService(io.micronaut.core.convert.ConversionService) ServerRequestContext(io.micronaut.http.context.ServerRequestContext) NOOP(io.micronaut.scheduling.instrument.InvocationInstrumenter.NOOP) MediaTypeCodecRegistry(io.micronaut.http.codec.MediaTypeCodecRegistry) Attribute(io.netty.util.Attribute) JsonNode(io.micronaut.json.tree.JsonNode) SslContext(io.netty.handler.ssl.SslContext) FileUpload(io.netty.handler.codec.http.multipart.FileUpload) Publisher(org.reactivestreams.Publisher) HttpClientConfiguration(io.micronaut.http.client.HttpClientConfiguration) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) NettyHttpResponseBuilder(io.micronaut.http.netty.NettyHttpResponseBuilder) File(java.io.File) AbstractNettyHttpRequest(io.micronaut.http.netty.AbstractNettyHttpRequest) SimpleChannelPool(io.netty.channel.pool.SimpleChannelPool) Bootstrap(io.netty.bootstrap.Bootstrap) Flux(reactor.core.publisher.Flux) WebSocketClientCompressionHandler(io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler) DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS(io.micronaut.http.client.HttpClientConfiguration.DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS) ChannelPipelineCustomizer(io.micronaut.http.netty.channel.ChannelPipelineCustomizer) ChannelPool(io.netty.channel.pool.ChannelPool) Instrumentation(io.micronaut.scheduling.instrument.Instrumentation) WebSocketClient(io.micronaut.websocket.WebSocketClient) Future(io.netty.util.concurrent.Future) DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) ChannelPipelineListener(io.micronaut.http.netty.channel.ChannelPipelineListener) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) SocketAddress(java.net.SocketAddress) HttpStreamsClientHandler(io.micronaut.http.netty.stream.HttpStreamsClientHandler) UriTemplate(io.micronaut.http.uri.UriTemplate) io.netty.handler.codec.http2(io.netty.handler.codec.http2) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) DEFAULT_SHUTDOWN_QUIET_PERIOD_MILLISECONDS(io.micronaut.http.client.HttpClientConfiguration.DEFAULT_SHUTDOWN_QUIET_PERIOD_MILLISECONDS) ArrayUtils(io.micronaut.core.util.ArrayUtils) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) InvocationInstrumenter(io.micronaut.scheduling.instrument.InvocationInstrumenter) InvocationInstrumenterFactory(io.micronaut.scheduling.instrument.InvocationInstrumenterFactory) ClientFilterChain(io.micronaut.http.filter.ClientFilterChain) DefaultHttp2Content(io.micronaut.http.netty.stream.DefaultHttp2Content) Event(io.micronaut.http.sse.Event) Unpooled(io.netty.buffer.Unpooled) FixedChannelPool(io.netty.channel.pool.FixedChannelPool) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MediaType(io.micronaut.http.MediaType) ReferenceCounted(io.micronaut.core.io.buffer.ReferenceCounted) JsonMapper(io.micronaut.json.JsonMapper) ApplicationProtocolNegotiationHandler(io.netty.handler.ssl.ApplicationProtocolNegotiationHandler) HttpResponse(io.micronaut.http.HttpResponse) ApplicationConfiguration(io.micronaut.runtime.ApplicationConfiguration) URI(java.net.URI) HttpClient(io.micronaut.http.client.HttpClient) HttpDataFactory(io.netty.handler.codec.http.multipart.HttpDataFactory) ThreadFactory(java.util.concurrent.ThreadFactory) RequestBinderRegistry(io.micronaut.http.bind.RequestBinderRegistry) MultipartBody(io.micronaut.http.client.multipart.MultipartBody) JsonMediaTypeCodec(io.micronaut.json.codec.JsonMediaTypeCodec) CodecException(io.micronaut.http.codec.CodecException) ReadTimeoutHandler(io.netty.handler.timeout.ReadTimeoutHandler) MutableHttpResponse(io.micronaut.http.MutableHttpResponse) MutableHttpHeaders(io.micronaut.http.MutableHttpHeaders) TooLongFrameException(io.netty.handler.codec.TooLongFrameException) InterfaceHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) StringUtils(io.micronaut.core.util.StringUtils) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) HttpClientFilter(io.micronaut.http.filter.HttpClientFilter) StreamedHttpRequest(io.micronaut.http.netty.stream.StreamedHttpRequest) io.netty.handler.codec.http(io.netty.handler.codec.http) StreamingHttpClient(io.micronaut.http.client.StreamingHttpClient) WebSocketSessionException(io.micronaut.websocket.exceptions.WebSocketSessionException) Type(java.net.Proxy.Type) Socks5ProxyHandler(io.netty.handler.proxy.Socks5ProxyHandler) ClientWebSocket(io.micronaut.websocket.annotation.ClientWebSocket) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) ClientServerContextFilter(io.micronaut.http.client.filters.ClientServerContextFilter) LoggingHandler(io.netty.handler.logging.LoggingHandler) UriBuilder(io.micronaut.http.uri.UriBuilder) HttpPostRequestEncoder(io.netty.handler.codec.http.multipart.HttpPostRequestEncoder) FluxSink(reactor.core.publisher.FluxSink) DefaultHttpDataFactory(io.netty.handler.codec.http.multipart.DefaultHttpDataFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HttpClientFilterResolver(io.micronaut.http.filter.HttpClientFilterResolver) Scheduler(reactor.core.scheduler.Scheduler) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) WebSocketBeanRegistry(io.micronaut.websocket.context.WebSocketBeanRegistry) BeanMap(io.micronaut.core.beans.BeanMap) NoopAddressResolverGroup(io.netty.resolver.NoopAddressResolverGroup) WebSocketVersion(io.netty.handler.codec.http.websocketx.WebSocketVersion) BlockingHttpClient(io.micronaut.http.client.BlockingHttpClient) ByteBuf(io.netty.buffer.ByteBuf) Charset(java.nio.charset.Charset) HttpClientException(io.micronaut.http.client.exceptions.HttpClientException) io.netty.channel(io.netty.channel) Schedulers(reactor.core.scheduler.Schedulers) HttpResponseWrapper(io.micronaut.http.HttpResponseWrapper) Subscriber(org.reactivestreams.Subscriber) MediaTypeCodec(io.micronaut.http.codec.MediaTypeCodec) Logger(org.slf4j.Logger) DefaultRequestBinderRegistry(io.micronaut.http.bind.DefaultRequestBinderRegistry) MalformedURLException(java.net.MalformedURLException) AnnotationMetadataResolver(io.micronaut.core.annotation.AnnotationMetadataResolver) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) ApplicationProtocolNames(io.netty.handler.ssl.ApplicationProtocolNames) DefaultHttpClientFilterResolver(io.micronaut.http.client.filter.DefaultHttpClientFilterResolver) Http2Content(io.micronaut.http.netty.stream.Http2Content) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NonNull(io.micronaut.core.annotation.NonNull) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) ByteBufUtil(io.netty.buffer.ByteBufUtil) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) CollectionUtils(io.micronaut.core.util.CollectionUtils) Subscription(org.reactivestreams.Subscription) Closeable(java.io.Closeable) AnnotationMetadata(io.micronaut.core.annotation.AnnotationMetadata) AbstractChannelPoolMap(io.netty.channel.pool.AbstractChannelPoolMap) JsonSubscriber(io.micronaut.http.netty.stream.JsonSubscriber) InputStream(java.io.InputStream) StreamedHttpResponse(io.micronaut.http.netty.stream.StreamedHttpResponse) DefaultStreamedHttpResponse(io.micronaut.http.netty.stream.DefaultStreamedHttpResponse) SocketChannel(io.netty.channel.socket.SocketChannel) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Flux(reactor.core.publisher.Flux) JsonNode(io.micronaut.json.tree.JsonNode) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) ByteBuf(io.netty.buffer.ByteBuf) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) MapperMediaTypeCodec(io.micronaut.json.codec.MapperMediaTypeCodec) io.netty.handler.codec.http(io.netty.handler.codec.http)

Aggregations

DefaultStreamedHttpResponse (io.micronaut.http.netty.stream.DefaultStreamedHttpResponse)4 StreamedHttpResponse (io.micronaut.http.netty.stream.StreamedHttpResponse)4 NonNull (io.micronaut.core.annotation.NonNull)3 Argument (io.micronaut.core.type.Argument)3 HttpResponse (io.micronaut.http.HttpResponse)3 HttpResponseWrapper (io.micronaut.http.HttpResponseWrapper)3 HttpStatus (io.micronaut.http.HttpStatus)3 MediaType (io.micronaut.http.MediaType)3 MutableHttpHeaders (io.micronaut.http.MutableHttpHeaders)3 MutableHttpRequest (io.micronaut.http.MutableHttpRequest)3 MutableHttpResponse (io.micronaut.http.MutableHttpResponse)3 ContentLengthExceededException (io.micronaut.http.client.exceptions.ContentLengthExceededException)3 HttpClientErrorDecoder (io.micronaut.http.client.exceptions.HttpClientErrorDecoder)3 HttpClientResponseException (io.micronaut.http.client.exceptions.HttpClientResponseException)3 Subscription (org.reactivestreams.Subscription)3 HttpClientException (io.micronaut.http.client.exceptions.HttpClientException)2 NoHostException (io.micronaut.http.client.exceptions.NoHostException)2 ReadTimeoutException (io.micronaut.http.client.exceptions.ReadTimeoutException)2 CodecException (io.micronaut.http.codec.CodecException)2 MultipartException (io.micronaut.http.multipart.MultipartException)2