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

io.vertx.rxjava3.core.http.HttpServerResponse Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show 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.rxjava3.core.http;

import io.vertx.rxjava3.RxHelper;
import io.vertx.rxjava3.ObservableHelper;
import io.vertx.rxjava3.FlowableHelper;
import io.vertx.rxjava3.impl.AsyncResultMaybe;
import io.vertx.rxjava3.impl.AsyncResultSingle;
import io.vertx.rxjava3.impl.AsyncResultCompletable;
import io.vertx.rxjava3.WriteStreamObserver;
import io.vertx.rxjava3.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.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 server-side HTTP response.
 * 

* An instance of this is created and associated to every instance of * {@link io.vertx.rxjava3.core.http.HttpServerRequest} that. *

* It allows the developer to control the HTTP response that is sent back to the * client for a particular HTTP request. *

* It contains methods that allow HTTP headers and trailers to be set, and for a body to be written out to the response. *

* It also allows files to be streamed by the kernel directly from disk to the * outgoing HTTP connection, bypassing user space altogether (where supported by * the underlying operating system). This is a very efficient way of * serving files from the server since buffers do not have to be read one by one * from the file and written to the outgoing socket. *

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

* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.HttpServerResponse original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.core.http.HttpServerResponse.class) public class HttpServerResponse implements io.vertx.rxjava3.core.streams.WriteStream { @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; HttpServerResponse that = (HttpServerResponse) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new HttpServerResponse((io.vertx.core.http.HttpServerResponse) obj), HttpServerResponse::getDelegate ); private final io.vertx.core.http.HttpServerResponse delegate; public HttpServerResponse(io.vertx.core.http.HttpServerResponse delegate) { this.delegate = delegate; } public HttpServerResponse(Object delegate) { this.delegate = (io.vertx.core.http.HttpServerResponse)delegate; } public io.vertx.core.http.HttpServerResponse getDelegate() { return delegate; } private WriteStreamObserver observer; private WriteStreamSubscriber subscriber; public synchronized WriteStreamObserver toObserver() { if (observer == null) { Function conv = io.vertx.rxjava3.core.buffer.Buffer::getDelegate; observer = RxHelper.toObserver(getDelegate(), conv); } return observer; } public synchronized WriteStreamSubscriber toSubscriber() { if (subscriber == null) { Function conv = io.vertx.rxjava3.core.buffer.Buffer::getDelegate; subscriber = RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; } private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.rxjava3.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_1 = new TypeArg(o1 -> io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_2 = new TypeArg(o1 -> io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)o1), o1 -> o1.getDelegate()); /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable write(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxWrite(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWrite(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.write(data.getDelegate(), handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @return */ public io.reactivex.rxjava3.core.Completable end() { io.reactivex.rxjava3.core.Completable ret = rxEnd(); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @return */ public io.reactivex.rxjava3.core.Completable rxEnd() { return AsyncResultCompletable.toCompletable( handler -> { delegate.end(handler); }); } /** * This will return true if there are more bytes in the write queue than the value set using {@link io.vertx.rxjava3.core.http.HttpServerResponse#setWriteQueueMaxSize} * @return true if write queue is full */ public boolean writeQueueFull() { boolean ret = delegate.writeQueueFull(); return ret; } public io.vertx.rxjava3.core.http.HttpServerResponse exceptionHandler(io.vertx.core.Handler handler) { delegate.exceptionHandler(handler); return this; } public io.vertx.rxjava3.core.http.HttpServerResponse setWriteQueueMaxSize(int maxSize) { delegate.setWriteQueueMaxSize(maxSize); return this; } public io.vertx.rxjava3.core.http.HttpServerResponse drainHandler(io.vertx.core.Handler handler) { delegate.drainHandler(handler); return this; } /** * @return the HTTP status code of the response. The default is 200 representing OK. */ public int getStatusCode() { int ret = delegate.getStatusCode(); return ret; } /** * Set the status code. If the status message hasn't been explicitly set, a default status message corresponding * to the code will be looked-up and used. * @param statusCode * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse setStatusCode(int statusCode) { delegate.setStatusCode(statusCode); return this; } /** * @return the HTTP status message of the response. If this is not specified a default value will be used depending on what {@link io.vertx.rxjava3.core.http.HttpServerResponse#setStatusCode} has been set to. */ public java.lang.String getStatusMessage() { java.lang.String ret = delegate.getStatusMessage(); return ret; } /** * Set the status message * @param statusMessage * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse setStatusMessage(java.lang.String statusMessage) { delegate.setStatusMessage(statusMessage); return this; } /** * If chunked is true, this response will use HTTP chunked encoding, and each call to write to the body * will correspond to a new HTTP chunk sent on the wire. *

* If chunked encoding is used the HTTP header Transfer-Encoding with a value of Chunked will be * automatically inserted in the response. *

* If chunked is false, this response will not use HTTP chunked encoding, and therefore the total size * of any data that is written in the respone body must be set in the Content-Length header before any * data is written out. *

* An HTTP chunked response is typically used when you do not know the total size of the request body up front. * @param chunked * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse setChunked(boolean chunked) { delegate.setChunked(chunked); return this; } /** * @return is the response chunked? */ public boolean isChunked() { boolean ret = delegate.isChunked(); return ret; } /** * @return The HTTP headers */ public io.vertx.rxjava3.core.MultiMap headers() { if (cached_0 != null) { return cached_0; } io.vertx.rxjava3.core.MultiMap ret = io.vertx.rxjava3.core.MultiMap.newInstance((io.vertx.core.MultiMap)delegate.headers()); cached_0 = ret; return ret; } /** * Put an HTTP header * @param name the header name * @param value the header value. * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse putHeader(java.lang.String name, java.lang.String value) { delegate.putHeader(name, value); return this; } /** * @return The HTTP trailers */ public io.vertx.rxjava3.core.MultiMap trailers() { if (cached_1 != null) { return cached_1; } io.vertx.rxjava3.core.MultiMap ret = io.vertx.rxjava3.core.MultiMap.newInstance((io.vertx.core.MultiMap)delegate.trailers()); cached_1 = ret; return ret; } /** * Put an HTTP trailer * @param name the trailer name * @param value the trailer value * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse putTrailer(java.lang.String name, java.lang.String value) { delegate.putTrailer(name, value); return this; } /** * Set a close handler for the response, this is called when the underlying connection is closed and the response * was still using the connection. *

* For HTTP/1.x it is called when the connection is closed before end() is called, therefore it is not * guaranteed to be called. *

* For HTTP/2 it is called when the related stream is closed, and therefore it will be always be called. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse closeHandler(io.vertx.core.Handler handler) { delegate.closeHandler(handler); return this; } /** * Set an end handler for the response. This will be called when the response is disposed to allow consistent cleanup * of the response. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse endHandler(io.vertx.core.Handler handler) { delegate.endHandler(handler); return this; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#write} but with an handler called when the operation completes * @param chunk * @param enc * @return */ public io.reactivex.rxjava3.core.Completable write(java.lang.String chunk, java.lang.String enc) { io.reactivex.rxjava3.core.Completable ret = rxWrite(chunk, enc); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#write} but with an handler called when the operation completes * @param chunk * @param enc * @return */ public io.reactivex.rxjava3.core.Completable rxWrite(java.lang.String chunk, java.lang.String enc) { return AsyncResultCompletable.toCompletable( handler -> { delegate.write(chunk, enc, handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#write} but with an handler called when the operation completes * @param chunk * @return */ public io.reactivex.rxjava3.core.Completable write(java.lang.String chunk) { io.reactivex.rxjava3.core.Completable ret = rxWrite(chunk); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#write} but with an handler called when the operation completes * @param chunk * @return */ public io.reactivex.rxjava3.core.Completable rxWrite(java.lang.String chunk) { return AsyncResultCompletable.toCompletable( handler -> { delegate.write(chunk, handler); }); } /** * Used to write an interim 100 Continue response to signify that the client should send the rest of the request. * Must only be used if the request contains an "Expect:100-Continue" header * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse writeContinue() { delegate.writeContinue(); return this; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#writeEarlyHints} but with an handler called when the operation completes * @param headers headers to write * @return */ public io.reactivex.rxjava3.core.Completable writeEarlyHints(io.vertx.rxjava3.core.MultiMap headers) { io.reactivex.rxjava3.core.Completable ret = rxWriteEarlyHints(headers); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#writeEarlyHints} but with an handler called when the operation completes * @param headers headers to write * @return */ public io.reactivex.rxjava3.core.Completable rxWriteEarlyHints(io.vertx.rxjava3.core.MultiMap headers) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writeEarlyHints(headers.getDelegate(), handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @param chunk * @return */ public io.reactivex.rxjava3.core.Completable end(java.lang.String chunk) { io.reactivex.rxjava3.core.Completable ret = rxEnd(chunk); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @param chunk * @return */ public io.reactivex.rxjava3.core.Completable rxEnd(java.lang.String chunk) { return AsyncResultCompletable.toCompletable( handler -> { delegate.end(chunk, handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @param chunk * @param enc * @return */ public io.reactivex.rxjava3.core.Completable end(java.lang.String chunk, java.lang.String enc) { io.reactivex.rxjava3.core.Completable ret = rxEnd(chunk, enc); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @param chunk * @param enc * @return */ public io.reactivex.rxjava3.core.Completable rxEnd(java.lang.String chunk, java.lang.String enc) { return AsyncResultCompletable.toCompletable( handler -> { delegate.end(chunk, enc, handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @param chunk * @return */ public io.reactivex.rxjava3.core.Completable end(io.vertx.rxjava3.core.buffer.Buffer chunk) { io.reactivex.rxjava3.core.Completable ret = rxEnd(chunk); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#end} but with an handler called when the operation completes * @param chunk * @return */ public io.reactivex.rxjava3.core.Completable rxEnd(io.vertx.rxjava3.core.buffer.Buffer chunk) { return AsyncResultCompletable.toCompletable( handler -> { delegate.end(chunk.getDelegate(), handler); }); } /** * Send the request with an empty body. * @return */ public io.reactivex.rxjava3.core.Completable send() { io.reactivex.rxjava3.core.Completable ret = rxSend(); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Send the request with an empty body. * @return */ public io.reactivex.rxjava3.core.Completable rxSend() { return AsyncResultCompletable.toCompletable( handler -> { delegate.send(handler); }); } /** * Send the request with a string body. * @param body * @return */ public io.reactivex.rxjava3.core.Completable send(java.lang.String body) { io.reactivex.rxjava3.core.Completable ret = rxSend(body); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Send the request with a string body. * @param body * @return */ public io.reactivex.rxjava3.core.Completable rxSend(java.lang.String body) { return AsyncResultCompletable.toCompletable( handler -> { delegate.send(body, handler); }); } /** * Send the request with a buffer body. * @param body * @return */ public io.reactivex.rxjava3.core.Completable send(io.vertx.rxjava3.core.buffer.Buffer body) { io.reactivex.rxjava3.core.Completable ret = rxSend(body); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Send the request with a buffer body. * @param body * @return */ public io.reactivex.rxjava3.core.Completable rxSend(io.vertx.rxjava3.core.buffer.Buffer body) { return AsyncResultCompletable.toCompletable( handler -> { delegate.send(body.getDelegate(), handler); }); } /** * Send the request with a stream body. * *

If the {@link io.vertx.rxjava3.core.http.HttpHeaders} is set then the request assumes this is the * length of the {stream}, otherwise the request will set a chunked {@link io.vertx.rxjava3.core.http.HttpHeaders}. * @param body * @return */ public io.reactivex.rxjava3.core.Completable send(io.reactivex.rxjava3.core.Flowable body) { io.reactivex.rxjava3.core.Completable ret = rxSend(body); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Send the request with a stream body. * *

If the {@link io.vertx.rxjava3.core.http.HttpHeaders} is set then the request assumes this is the * length of the {stream}, otherwise the request will set a chunked {@link io.vertx.rxjava3.core.http.HttpHeaders}. * @param body * @return */ public io.reactivex.rxjava3.core.Completable rxSend(io.reactivex.rxjava3.core.Flowable body) { return AsyncResultCompletable.toCompletable( handler -> { delegate.send(io.vertx.rxjava3.impl.ReadStreamSubscriber.asReadStream(body, obj -> obj.getDelegate()).resume(), handler); }); } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#sendFile} but providing a handler which will be notified once the file has been completely * written to the wire. * @param filename path to the file to serve * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable sendFile(java.lang.String filename) { io.reactivex.rxjava3.core.Completable ret = rxSendFile(filename); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#sendFile} but providing a handler which will be notified once the file has been completely * written to the wire. * @param filename path to the file to serve * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxSendFile(java.lang.String filename) { return AsyncResultCompletable.toCompletable( resultHandler -> { delegate.sendFile(filename, resultHandler); }); } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#sendFile} but providing a handler which will be notified once the file has been completely * written to the wire. * @param filename path to the file to serve * @param offset the offset to serve from * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable sendFile(java.lang.String filename, long offset) { io.reactivex.rxjava3.core.Completable ret = rxSendFile(filename, offset); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#sendFile} but providing a handler which will be notified once the file has been completely * written to the wire. * @param filename path to the file to serve * @param offset the offset to serve from * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxSendFile(java.lang.String filename, long offset) { return AsyncResultCompletable.toCompletable( resultHandler -> { delegate.sendFile(filename, offset, resultHandler); }); } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#sendFile} but providing a handler which will be notified once the file has been * completely written to the wire. * @param filename path to the file to serve * @param offset the offset to serve from * @param length length the number of bytes to send * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable sendFile(java.lang.String filename, long offset, long length) { io.reactivex.rxjava3.core.Completable ret = rxSendFile(filename, offset, length); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#sendFile} but providing a handler which will be notified once the file has been * completely written to the wire. * @param filename path to the file to serve * @param offset the offset to serve from * @param length length the number of bytes to send * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxSendFile(java.lang.String filename, long offset, long length) { return AsyncResultCompletable.toCompletable( resultHandler -> { delegate.sendFile(filename, offset, length, resultHandler); }); } /** * Close the underlying TCP connection corresponding to the request. */ @Deprecated() public void close() { delegate.close(); } /** * @return has the response already ended? */ public boolean ended() { boolean ret = delegate.ended(); return ret; } /** * @return has the underlying TCP connection corresponding to the request already been closed? */ public boolean closed() { boolean ret = delegate.closed(); return ret; } /** * @return have the headers for the response already been written? */ public boolean headWritten() { boolean ret = delegate.headWritten(); return ret; } /** * Provide a handler that will be called just before the headers are written to the wire.

* This provides a hook allowing you to add any more headers or do any more operations before this occurs. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse headersEndHandler(io.vertx.core.Handler handler) { delegate.headersEndHandler(handler); return this; } /** * Provides a handler that will be called after the last part of the body is written to the wire. * The handler is called asynchronously of when the response has been received by the client. * This provides a hook allowing you to do more operations once the request has been sent over the wire * such as resource cleanup. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse bodyEndHandler(io.vertx.core.Handler handler) { delegate.bodyEndHandler(handler); return this; } /** * @return the total number of bytes written for the body of the response. */ public long bytesWritten() { long ret = delegate.bytesWritten(); return ret; } /** * @return the id of the stream of this response, for HTTP/1.x */ public int streamId() { int ret = delegate.streamId(); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} with no headers. * @param method * @param host * @param path * @return */ public io.reactivex.rxjava3.core.Single push(io.vertx.core.http.HttpMethod method, java.lang.String host, java.lang.String path) { io.reactivex.rxjava3.core.Single ret = rxPush(method, host, path); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} with no headers. * @param method * @param host * @param path * @return */ public io.reactivex.rxjava3.core.Single rxPush(io.vertx.core.http.HttpMethod method, java.lang.String host, java.lang.String path) { return AsyncResultSingle.toSingle( handler -> { delegate.push(method, host, path, new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)event)))); }); } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @param headers * @return */ public io.reactivex.rxjava3.core.Single push(io.vertx.core.http.HttpMethod method, java.lang.String path, io.vertx.rxjava3.core.MultiMap headers) { io.reactivex.rxjava3.core.Single ret = rxPush(method, path, headers); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @param headers * @return */ public io.reactivex.rxjava3.core.Single rxPush(io.vertx.core.http.HttpMethod method, java.lang.String path, io.vertx.rxjava3.core.MultiMap headers) { return AsyncResultSingle.toSingle( handler -> { delegate.push(method, path, headers.getDelegate(), new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)event)))); }); } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @return */ public io.reactivex.rxjava3.core.Single push(io.vertx.core.http.HttpMethod method, java.lang.String path) { io.reactivex.rxjava3.core.Single ret = rxPush(method, path); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @return */ public io.reactivex.rxjava3.core.Single rxPush(io.vertx.core.http.HttpMethod method, java.lang.String path) { return AsyncResultSingle.toSingle( handler -> { delegate.push(method, path, new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)event)))); }); } /** * Push a response to the client.

* * The handler will be notified with a success when the push can be sent and with * a failure when the client has disabled push or reset the push before it has been sent.

* * The handler may be queued if the client has reduced the maximum number of streams the server can push * concurrently.

* * Push can be sent only for peer initiated streams and if the response is not ended. * @param method the method of the promised request * @param host * @param path the path of the promised request * @param headers the headers of the promised request * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Single push(io.vertx.core.http.HttpMethod method, java.lang.String host, java.lang.String path, io.vertx.rxjava3.core.MultiMap headers) { io.reactivex.rxjava3.core.Single ret = rxPush(method, host, path, headers); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Push a response to the client.

* * The handler will be notified with a success when the push can be sent and with * a failure when the client has disabled push or reset the push before it has been sent.

* * The handler may be queued if the client has reduced the maximum number of streams the server can push * concurrently.

* * Push can be sent only for peer initiated streams and if the response is not ended. * @param method the method of the promised request * @param host * @param path the path of the promised request * @param headers the headers of the promised request * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Single rxPush(io.vertx.core.http.HttpMethod method, java.lang.String host, java.lang.String path, io.vertx.rxjava3.core.MultiMap headers) { return AsyncResultSingle.toSingle( handler -> { delegate.push(method, host, path, headers.getDelegate(), new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)event)))); }); } /** * Same as {@link io.vertx.rxjava3.core.http.HttpServerResponse#push} but with an handler called when the operation completes * @param method * @param authority * @param path * @param headers * @return */ public io.vertx.core.Future push(io.vertx.core.http.HttpMethod method, io.vertx.rxjava3.core.net.HostAndPort authority, java.lang.String path, io.vertx.rxjava3.core.MultiMap headers) { io.vertx.core.Future ret = delegate.push(method, authority.getDelegate(), path, headers.getDelegate()).map(val -> io.vertx.rxjava3.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)val)); return ret; } /** * Reset this HTTP/2 stream with the error code 0. * @return */ public boolean reset() { boolean ret = delegate.reset(); return ret; } /** * Reset this response: *

*

    *
  • for HTTP/2, send an HTTP/2 reset frame with the specified error code
  • *
  • for HTTP/1.x, close the connection when the current response has not yet been sent
  • *
*

* When the response has already been sent nothing happens and false is returned as indicator. * @param code the error code * @return true when reset has been performed */ public boolean reset(long code) { boolean ret = delegate.reset(code); return ret; } /** * Write an HTTP/2 frame to the response, allowing to extend the HTTP/2 protocol.

* * The frame is sent immediatly and is not subject to flow control. * @param type the 8-bit frame type * @param flags the 8-bit frame flags * @param payload the frame payload * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse writeCustomFrame(int type, int flags, io.vertx.rxjava3.core.buffer.Buffer payload) { delegate.writeCustomFrame(type, flags, payload.getDelegate()); return this; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#writeCustomFrame} but with an {@link io.vertx.rxjava3.core.http.HttpFrame}. * @param frame the frame to write * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse writeCustomFrame(io.vertx.rxjava3.core.http.HttpFrame frame) { delegate.writeCustomFrame(frame.getDelegate()); return this; } /** * Sets the priority of the associated stream *

* This is not implemented for HTTP/1.x. * @param streamPriority the priority for this request's stream * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse setStreamPriority(io.vertx.core.http.StreamPriority streamPriority) { delegate.setStreamPriority(streamPriority); return this; } /** * Add a cookie. This will be sent back to the client in the response. * @param cookie the cookie * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.HttpServerResponse addCookie(io.vertx.rxjava3.core.http.Cookie cookie) { delegate.addCookie(cookie.getDelegate()); return this; } /** * Expire a cookie, notifying a User Agent to remove it from its cookie jar. * * NOTE: This method will only remove the first occurrence of the given name. Users probably may want to use: * {@link io.vertx.rxjava3.core.http.HttpServerResponse#removeCookies} * @param name the name of the cookie * @return the cookie, if it existed, or null */ public io.vertx.rxjava3.core.http.Cookie removeCookie(java.lang.String name) { io.vertx.rxjava3.core.http.Cookie ret = io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.removeCookie(name)); return ret; } /** * Remove a cookie from the cookie set. If invalidate is true then it will expire a cookie, notifying a User * Agent to remove it from its cookie jar. * * NOTE: This method will only expire the first occurrence of the given name. Users probably may want to use: * {@link io.vertx.rxjava3.core.http.HttpServerResponse#removeCookies} * @param name the name of the cookie * @param invalidate * @return the cookie, if it existed, or null */ public io.vertx.rxjava3.core.http.Cookie removeCookie(java.lang.String name, boolean invalidate) { io.vertx.rxjava3.core.http.Cookie ret = io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.removeCookie(name, invalidate)); return ret; } /** * Expire all cookies, notifying a User Agent to remove it from its cookie jar. * * NOTE: the returned is read-only. This means any attempt to modify (add or remove to the set), will * throw {@link java.lang.UnsupportedOperationException}. * @param name the name of the cookie * @return a read only set of affected cookies, if they existed, or an empty set. */ public java.util.Set removeCookies(java.lang.String name) { java.util.Set ret = delegate.removeCookies(name).stream().map(elt -> io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)elt)).collect(Collectors.toSet()); return ret; } /** * Remove all cookies from the cookie set. If invalidate is true then it will expire a cookie, notifying a * User Agent to remove it from its cookie jar. * * NOTE: the returned is read-only. This means any attempt to modify (add or remove to the set), will * throw {@link java.lang.UnsupportedOperationException}. * @param name the name of the cookie * @param invalidate invalidate from the user agent * @return a read only set of affected cookies, if they existed, or an empty set. */ public java.util.Set removeCookies(java.lang.String name, boolean invalidate) { java.util.Set ret = delegate.removeCookies(name, invalidate).stream().map(elt -> io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)elt)).collect(Collectors.toSet()); return ret; } /** * Expires a cookie from the cookie set. This will notify a User Agent to remove it from its cookie jar. * @param name the name of the cookie * @param domain the domain of the cookie * @param path the path of the cookie * @return the cookie, if it existed, or null */ public io.vertx.rxjava3.core.http.Cookie removeCookie(java.lang.String name, java.lang.String domain, java.lang.String path) { io.vertx.rxjava3.core.http.Cookie ret = io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.removeCookie(name, domain, path)); return ret; } /** * Remove a cookie from the cookie set. If invalidate is true then it will expire a cookie, notifying a User * Agent to remove it from its cookie jar. * @param name the name of the cookie * @param domain the domain of the cookie * @param path the path of the cookie * @param invalidate * @return the cookie, if it existed, or null */ public io.vertx.rxjava3.core.http.Cookie removeCookie(java.lang.String name, java.lang.String domain, java.lang.String path, boolean invalidate) { io.vertx.rxjava3.core.http.Cookie ret = io.vertx.rxjava3.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.removeCookie(name, domain, path, invalidate)); return ret; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#putHeader} but using CharSequence * @param name * @param value * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse putHeader(java.lang.CharSequence name, java.lang.CharSequence value) { delegate.putHeader(name, value); return this; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#putHeader} but providing multiple values via a String Iterable * @param name * @param values * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse putHeader(java.lang.String name, java.lang.Iterable values) { delegate.putHeader(name, values); return this; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#putHeader} but with CharSequence Iterable * @param name * @param values * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse putHeader(java.lang.CharSequence name, java.lang.Iterable values) { delegate.putHeader(name, values); return this; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#putTrailer} but using CharSequence * @param name * @param value * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse putTrailer(java.lang.CharSequence name, java.lang.CharSequence value) { delegate.putTrailer(name, value); return this; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#putTrailer} but providing multiple values via a String Iterable * @param name * @param values * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse putTrailer(java.lang.String name, java.lang.Iterable values) { delegate.putTrailer(name, values); return this; } /** * Like {@link io.vertx.rxjava3.core.http.HttpServerResponse#putTrailer} but with CharSequence Iterable * @param name * @param value * @return */ public io.vertx.rxjava3.core.http.HttpServerResponse putTrailer(java.lang.CharSequence name, java.lang.Iterable value) { delegate.putTrailer(name, value); return this; } private io.vertx.rxjava3.core.MultiMap cached_0; private io.vertx.rxjava3.core.MultiMap cached_1; public static HttpServerResponse newInstance(io.vertx.core.http.HttpServerResponse arg) { return arg != null ? new HttpServerResponse(arg) : null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy