All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.reactivex.core.http.HttpClientResponse Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.reactivex.core.http;

import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

/**
 * Represents a client-side HTTP response.
 * 

* Vert.x provides you with one of these via the handler that was provided when creating the {@link io.vertx.reactivex.core.http.HttpClientRequest} * or that was set on the {@link io.vertx.reactivex.core.http.HttpClientRequest} instance. *

* It implements {@link io.vertx.reactivex.core.streams.ReadStream} so it can be used with * {@link io.vertx.reactivex.core.streams.Pipe} to pipe data with flow control. * *

* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.HttpClientResponse original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.core.http.HttpClientResponse.class) public class HttpClientResponse implements io.vertx.reactivex.core.streams.ReadStream, io.vertx.reactivex.core.http.HttpResponseHead { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HttpClientResponse that = (HttpClientResponse) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new HttpClientResponse((io.vertx.core.http.HttpClientResponse) obj), HttpClientResponse::getDelegate ); private final io.vertx.core.http.HttpClientResponse delegate; public HttpClientResponse(io.vertx.core.http.HttpClientResponse delegate) { this.delegate = delegate; } public HttpClientResponse(Object delegate) { this.delegate = (io.vertx.core.http.HttpClientResponse)delegate; } public io.vertx.core.http.HttpClientResponse getDelegate() { return delegate; } private io.reactivex.Observable observable; private io.reactivex.Flowable flowable; public synchronized io.reactivex.Observable toObservable() { if (observable == null) { observable = ObservableHelper.toObservable(this.getDelegate()); } return observable; } public synchronized io.reactivex.Flowable toFlowable() { if (flowable == null) { flowable = FlowableHelper.toFlowable(this.getDelegate()); } return flowable; } /** * @return the version of the response */ public io.vertx.core.http.HttpVersion version() { io.vertx.core.http.HttpVersion ret = delegate.version(); return ret; } /** * @return the status code of the response */ public int statusCode() { int ret = delegate.statusCode(); return ret; } /** * @return the status message of the response */ public java.lang.String statusMessage() { java.lang.String ret = delegate.statusMessage(); return ret; } /** * @return the headers */ public io.vertx.core.MultiMap headers() { if (cached_0 != null) { return cached_0; } io.vertx.core.MultiMap ret = delegate.headers(); cached_0 = ret; return ret; } /** * Return the first header value with the specified name * @param headerName the header name * @return the header value */ public java.lang.String getHeader(java.lang.String headerName) { java.lang.String ret = delegate.getHeader(headerName); return ret; } /** * @return the Set-Cookie headers (including trailers) */ public java.util.List cookies() { if (cached_1 != null) { return cached_1; } java.util.List ret = delegate.cookies(); cached_1 = ret; return ret; } /** * Pause this stream and return a to transfer the elements of this stream to a destination . *

* The stream will be resumed when the pipe will be wired to a WriteStream. * @return a pipe */ public io.vertx.reactivex.core.streams.Pipe pipe() { io.vertx.reactivex.core.streams.Pipe ret = io.vertx.reactivex.core.streams.Pipe.newInstance((io.vertx.core.streams.Pipe)delegate.pipe(), TypeArg.unknown()); return ret; } /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. * @param dst the destination write stream * @return a future notified when the write stream will be ended with the outcome */ public io.vertx.core.Future pipeTo(io.vertx.reactivex.core.streams.WriteStream dst) { io.vertx.core.Future ret = delegate.pipeTo(dst.getDelegate()).map(val -> val); return ret; } /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. * @param dst the destination write stream * @return a future notified when the write stream will be ended with the outcome */ public io.reactivex.Completable rxPipeTo(io.vertx.reactivex.core.streams.WriteStream dst) { return AsyncResultCompletable.toCompletable($handler -> { this.pipeTo(dst).onComplete($handler); }); } public io.vertx.reactivex.core.http.HttpClientResponse fetch(long amount) { delegate.fetch(amount); return this; } public io.vertx.reactivex.core.http.HttpClientResponse resume() { delegate.resume(); return this; } public io.vertx.reactivex.core.http.HttpClientResponse exceptionHandler(io.vertx.core.Handler handler) { delegate.exceptionHandler(handler); return this; } public io.vertx.reactivex.core.http.HttpClientResponse handler(io.vertx.core.Handler handler) { delegate.handler(handler); return this; } public io.vertx.reactivex.core.http.HttpClientResponse pause() { delegate.pause(); return this; } public io.vertx.reactivex.core.http.HttpClientResponse endHandler(io.vertx.core.Handler endHandler) { delegate.endHandler(endHandler); return this; } /** * @return a NetSocket facade to interact with the HTTP client response. */ public io.vertx.reactivex.core.net.NetSocket netSocket() { if (cached_2 != null) { return cached_2; } io.vertx.reactivex.core.net.NetSocket ret = io.vertx.reactivex.core.net.NetSocket.newInstance((io.vertx.core.net.NetSocket)delegate.netSocket()); cached_2 = ret; return ret; } /** * Return the first trailer value with the specified name * @param trailerName the trailer name * @return the trailer value */ public java.lang.String getTrailer(java.lang.String trailerName) { java.lang.String ret = delegate.getTrailer(trailerName); return ret; } /** * @return the trailers */ public io.vertx.core.MultiMap trailers() { if (cached_3 != null) { return cached_3; } io.vertx.core.MultiMap ret = delegate.trailers(); cached_3 = ret; return ret; } /** * Convenience method for receiving the entire request body in one piece. *

* This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until * the whole body received. Don't use this if your request body is large - you could potentially run out of RAM. * @param bodyHandler This handler will be called after all the body has been received * @return */ public io.vertx.reactivex.core.http.HttpClientResponse bodyHandler(io.vertx.core.Handler bodyHandler) { delegate.bodyHandler(bodyHandler); return this; } /** * Convenience method for receiving the entire request body in one piece. *

* This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until * the whole body received. Don't use this if your request body is large - you could potentially run out of RAM. * @return a future completed with the body result */ public io.vertx.core.Future body() { io.vertx.core.Future ret = delegate.body().map(val -> val); return ret; } /** * Convenience method for receiving the entire request body in one piece. *

* This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until * the whole body received. Don't use this if your request body is large - you could potentially run out of RAM. * @return a future completed with the body result */ public io.reactivex.Single rxBody() { return AsyncResultSingle.toSingle($handler -> { this.body().onComplete($handler); }); } /** * Returns a future signaling when the response has been fully received successfully or failed. * @return a future completed with the body result */ public io.vertx.core.Future end() { io.vertx.core.Future ret = delegate.end().map(val -> val); return ret; } /** * Returns a future signaling when the response has been fully received successfully or failed. * @return a future completed with the body result */ public io.reactivex.Completable rxEnd() { return AsyncResultCompletable.toCompletable($handler -> { this.end().onComplete($handler); }); } /** * Set an custom frame handler. The handler will get notified when the http stream receives an custom HTTP/2 * frame. HTTP/2 permits extension of the protocol. * @param handler * @return a reference to this, so the API can be used fluently */ public io.vertx.reactivex.core.http.HttpClientResponse customFrameHandler(io.vertx.core.Handler handler) { delegate.customFrameHandler(handler); return this; } /** * @return the corresponding request */ public io.vertx.reactivex.core.http.HttpClientRequest request() { if (cached_4 != null) { return cached_4; } io.vertx.reactivex.core.http.HttpClientRequest ret = io.vertx.reactivex.core.http.HttpClientRequest.newInstance((io.vertx.core.http.HttpClientRequest)delegate.request()); cached_4 = ret; return ret; } /** * Set an handler for stream priority changes. *

* This is not implemented for HTTP/1.x. * @param handler the handler to be called when the stream priority changes * @return */ public io.vertx.reactivex.core.http.HttpClientResponse streamPriorityHandler(io.vertx.core.Handler handler) { delegate.streamPriorityHandler(handler); return this; } /** * Return the first header value with the specified name * @param headerName the header name * @return the header value */ public java.lang.String getHeader(java.lang.CharSequence headerName) { java.lang.String ret = delegate.getHeader(headerName); return ret; } private io.vertx.core.MultiMap cached_0; private java.util.List cached_1; private io.vertx.reactivex.core.net.NetSocket cached_2; private io.vertx.core.MultiMap cached_3; private io.vertx.reactivex.core.http.HttpClientRequest cached_4; public static HttpClientResponse newInstance(io.vertx.core.http.HttpClientResponse arg) { return arg != null ? new HttpClientResponse(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy