/*
* 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 java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.http.StreamPriority;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
Represents a server-side HTTP response.
An instance of this is created and associated to every instance of 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 WriteStream
so it can be used with Pump
to pump data with flow control.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* Represents a server-side HTTP response.
* <p>
* An instance of this is created and associated to every instance of
* {@link io.vertx.reactivex.core.http.HttpServerRequest} that.
* <p>
* It allows the developer to control the HTTP response that is sent back to the
* client for a particular HTTP request.
* <p>
* It contains methods that allow HTTP headers and trailers to be set, and for a body to be written out to the response.
* <p>
* 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.
* <p>
* It implements {@link io.vertx.reactivex.core.streams.WriteStream} so it can be used with
* {@link io.vertx.reactivex.core.streams.Pump} to pump data with flow control.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.HttpServerResponse original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rx.RxGen(io.vertx.core.http.HttpServerResponse.class)
public class HttpServerResponse implements io.vertx.reactivex.core.streams.WriteStream<io.vertx.reactivex.core.buffer.Buffer> {
@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 io.vertx.lang.rx.TypeArg<HttpServerResponse> __TYPE_ARG = new io.vertx.lang.rx.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 io.vertx.core.http.HttpServerResponse getDelegate() {
return delegate;
}
private io.vertx.reactivex.WriteStreamObserver<io.vertx.reactivex.core.buffer.Buffer> observer;
private io.vertx.reactivex.WriteStreamSubscriber<io.vertx.reactivex.core.buffer.Buffer> subscriber;
public synchronized io.vertx.reactivex.WriteStreamObserver<io.vertx.reactivex.core.buffer.Buffer> toObserver() {
if (observer == null) {
java.util.function.Function<io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.buffer.Buffer> conv = io.vertx.reactivex.core.buffer.Buffer::getDelegate;
observer = io.vertx.reactivex.RxHelper.toObserver(getDelegate(), conv);
}
return observer;
}
public synchronized io.vertx.reactivex.WriteStreamSubscriber<io.vertx.reactivex.core.buffer.Buffer> toSubscriber() {
if (subscriber == null) {
java.util.function.Function<io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.buffer.Buffer> conv = io.vertx.reactivex.core.buffer.Buffer::getDelegate;
subscriber = io.vertx.reactivex.RxHelper.toSubscriber(getDelegate(), conv);
}
return subscriber;
}
Same as end
but with an handler
called when the operation completes
Params: - handler –
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param handler
*/
public void end(Handler<AsyncResult<Void>> handler) {
delegate.end(handler);
}
Same as end
but with an handler
called when the operation completes
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @return
*/
public Completable rxEnd() {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(handler);
});
}
This will return true
if there are more bytes in the write queue than the value set using setWriteQueueMaxSize
Returns: true if write queue is full
/**
* This will return <code>true</code> if there are more bytes in the write queue than the value set using {@link io.vertx.reactivex.core.http.HttpServerResponse#setWriteQueueMaxSize}
* @return true if write queue is full
*/
public boolean writeQueueFull() {
boolean ret = delegate.writeQueueFull();
return ret;
}
public io.vertx.reactivex.core.http.HttpServerResponse exceptionHandler(Handler<Throwable> handler) {
delegate.exceptionHandler(handler);
return this;
}
public io.vertx.reactivex.core.http.HttpServerResponse write(io.vertx.reactivex.core.buffer.Buffer data) {
delegate.write(data.getDelegate());
return this;
}
Same as write
but with an handler
called when the operation completes
Params: - data –
- handler –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#write} but with an <code>handler</code> called when the operation completes
* @param data
* @param handler
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse write(io.vertx.reactivex.core.buffer.Buffer data, Handler<AsyncResult<Void>> handler) {
delegate.write(data.getDelegate(), handler);
return this;
}
Same as write
but with an handler
called when the operation completes
Params: - data –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#write} but with an <code>handler</code> called when the operation completes
* @param data
* @return
*/
public Completable rxWrite(io.vertx.reactivex.core.buffer.Buffer data) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
write(data, handler);
});
}
public io.vertx.reactivex.core.http.HttpServerResponse setWriteQueueMaxSize(int maxSize) {
delegate.setWriteQueueMaxSize(maxSize);
return this;
}
public io.vertx.reactivex.core.http.HttpServerResponse drainHandler(Handler<Void> handler) {
delegate.drainHandler(handler);
return this;
}
Returns: the HTTP status code of the response. The default is 200
representing OK
.
/**
* @return the HTTP status code of the response. The default is <code>200</code> representing <code>OK</code>.
*/
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.
Params: - statusCode –
Returns: a reference to this, so the API can be used fluently
/**
* 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.reactivex.core.http.HttpServerResponse setStatusCode(int statusCode) {
delegate.setStatusCode(statusCode);
return this;
}
Returns: the HTTP status message of the response. If this is not specified a default value will be used depending on what setStatusCode
has been set to.
/**
* @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.reactivex.core.http.HttpServerResponse#setStatusCode} has been set to.
*/
public String getStatusMessage() {
String ret = delegate.getStatusMessage();
return ret;
}
Set the status message
Params: - statusMessage –
Returns: a reference to this, so the API can be used fluently
/**
* Set the status message
* @param statusMessage
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse setStatusMessage(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.
Params: - chunked –
Returns: a reference to this, so the API can be used fluently
/**
* If <code>chunked</code> is <code>true</code>, 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.
* <p>
* If chunked encoding is used the HTTP header <code>Transfer-Encoding</code> with a value of <code>Chunked</code> will be
* automatically inserted in the response.
* <p>
* If <code>chunked</code> is <code>false</code>, 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 <code>Content-Length</code> header <b>before</b> any
* data is written out.
* <p>
* 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.reactivex.core.http.HttpServerResponse setChunked(boolean chunked) {
delegate.setChunked(chunked);
return this;
}
Returns: is the response chunked?
/**
* @return is the response chunked?
*/
public boolean isChunked() {
boolean ret = delegate.isChunked();
return ret;
}
Returns: The HTTP headers
/**
* @return The HTTP headers
*/
public io.vertx.reactivex.core.MultiMap headers() {
if (cached_0 != null) {
return cached_0;
}
io.vertx.reactivex.core.MultiMap ret = io.vertx.reactivex.core.MultiMap.newInstance(delegate.headers());
cached_0 = ret;
return ret;
}
Put an HTTP header
Params: - name – the header name
- value – the header value.
Returns: a reference to this, so the API can be used fluently
/**
* 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.reactivex.core.http.HttpServerResponse putHeader(String name, String value) {
delegate.putHeader(name, value);
return this;
}
Returns: The HTTP trailers
/**
* @return The HTTP trailers
*/
public io.vertx.reactivex.core.MultiMap trailers() {
if (cached_1 != null) {
return cached_1;
}
io.vertx.reactivex.core.MultiMap ret = io.vertx.reactivex.core.MultiMap.newInstance(delegate.trailers());
cached_1 = ret;
return ret;
}
Put an HTTP trailer
Params: - name – the trailer name
- value – the trailer value
Returns: a reference to this, so the API can be used fluently
/**
* 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.reactivex.core.http.HttpServerResponse putTrailer(String name, 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.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Set a close handler for the response, this is called when the underlying connection is closed and the response
* was still using the connection.
* <p>
* For HTTP/1.x it is called when the connection is closed before <code>end()</code> is called, therefore it is not
* guaranteed to be called.
* <p>
* 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.reactivex.core.http.HttpServerResponse closeHandler(Handler<Void> 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.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* 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.reactivex.core.http.HttpServerResponse endHandler(Handler<Void> handler) {
delegate.endHandler(handler);
return this;
}
Write a String
to the response body, encoded using the encoding enc
.
Params: - chunk – the string to write
- enc – the encoding to use
Returns: a reference to this, so the API can be used fluently
/**
* Write a {@link java.lang.String} to the response body, encoded using the encoding <code>enc</code>.
* @param chunk the string to write
* @param enc the encoding to use
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse write(String chunk, String enc) {
delegate.write(chunk, enc);
return this;
}
Same as write
but with an handler
called when the operation completes
Params: - chunk –
- enc –
- handler –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#write} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param enc
* @param handler
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse write(String chunk, String enc, Handler<AsyncResult<Void>> handler) {
delegate.write(chunk, enc, handler);
return this;
}
Same as write
but with an handler
called when the operation completes
Params: - chunk –
- enc –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#write} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param enc
* @return
*/
public Completable rxWrite(String chunk, String enc) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
write(chunk, enc, handler);
});
}
Write a String
to the response body, encoded in UTF-8. Params: - chunk – the string to write
Returns: a reference to this, so the API can be used fluently
/**
* Write a {@link java.lang.String} to the response body, encoded in UTF-8.
* @param chunk the string to write
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse write(String chunk) {
delegate.write(chunk);
return this;
}
Same as write
but with an handler
called when the operation completes
Params: - chunk –
- handler –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#write} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param handler
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse write(String chunk, Handler<AsyncResult<Void>> handler) {
delegate.write(chunk, handler);
return this;
}
Same as write
but with an handler
called when the operation completes
Params: - chunk –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#write} but with an <code>handler</code> called when the operation completes
* @param chunk
* @return
*/
public Completable rxWrite(String chunk) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
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
Returns: a reference to this, so the API can be used fluently
/**
* 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.reactivex.core.http.HttpServerResponse writeContinue() {
delegate.writeContinue();
return this;
}
Same as end
but writes a String in UTF-8 encoding before ending the response. Params: - chunk – the string to write before ending the response
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but writes a String in UTF-8 encoding before ending the response.
* @param chunk the string to write before ending the response
*/
public void end(String chunk) {
delegate.end(chunk);
}
Same as end
but with an handler
called when the operation completes
Params: - chunk –
- handler –
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param handler
*/
public void end(String chunk, Handler<AsyncResult<Void>> handler) {
delegate.end(chunk, handler);
}
Same as end
but with an handler
called when the operation completes
Params: - chunk –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param chunk
* @return
*/
public Completable rxEnd(String chunk) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(chunk, handler);
});
}
Same as end
but writes a String with the specified encoding before ending the response. Params: - chunk – the string to write before ending the response
- enc – the encoding to use
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but writes a String with the specified encoding before ending the response.
* @param chunk the string to write before ending the response
* @param enc the encoding to use
*/
public void end(String chunk, String enc) {
delegate.end(chunk, enc);
}
Same as end
but with an handler
called when the operation completes
Params: - chunk –
- enc –
- handler –
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param enc
* @param handler
*/
public void end(String chunk, String enc, Handler<AsyncResult<Void>> handler) {
delegate.end(chunk, enc, handler);
}
Same as end
but with an handler
called when the operation completes
Params: - chunk –
- enc –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param enc
* @return
*/
public Completable rxEnd(String chunk, String enc) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(chunk, enc, handler);
});
}
Same as end
but writes some data to the response body before ending. If the response is not chunked and no other data has been written then the @code{Content-Length} header will be automatically set. Params: - chunk – the buffer to write before ending the response
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but writes some data to the response body before ending. If the response is not chunked and
* no other data has been written then the @code{Content-Length} header will be automatically set.
* @param chunk the buffer to write before ending the response
*/
public void end(io.vertx.reactivex.core.buffer.Buffer chunk) {
delegate.end(chunk.getDelegate());
}
Same as end
but with an handler
called when the operation completes
Params: - chunk –
- handler –
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param chunk
* @param handler
*/
public void end(io.vertx.reactivex.core.buffer.Buffer chunk, Handler<AsyncResult<Void>> handler) {
delegate.end(chunk.getDelegate(), handler);
}
Same as end
but with an handler
called when the operation completes
Params: - chunk –
Returns:
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#end} but with an <code>handler</code> called when the operation completes
* @param chunk
* @return
*/
public Completable rxEnd(io.vertx.reactivex.core.buffer.Buffer chunk) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(chunk, handler);
});
}
Ends the response. If no data has been written to the response body,
the actual response won't get written until this method gets called.
Once the response has ended, it cannot be used any more.
/**
* Ends the response. If no data has been written to the response body,
* the actual response won't get written until this method gets called.
* <p>
* Once the response has ended, it cannot be used any more.
*/
public void end() {
delegate.end();
}
Same as sendFile
using offset @code{0} which means starting from the beginning of the file. Params: - filename – path to the file to serve
Returns: a reference to this, so the API can be used fluently
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#sendFile} using offset @code{0} which means starting from the beginning of the file.
* @param filename path to the file to serve
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse sendFile(String filename) {
delegate.sendFile(filename);
return this;
}
Same as sendFile
using length @code{Long.MAX_VALUE} which means until the end of the file. Params: - filename – path to the file to serve
- offset – offset to start serving from
Returns: a reference to this, so the API can be used fluently
/**
* Same as {@link io.vertx.reactivex.core.http.HttpServerResponse#sendFile} using length @code{Long.MAX_VALUE} which means until the end of the
* file.
* @param filename path to the file to serve
* @param offset offset to start serving from
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse sendFile(String filename, long offset) {
delegate.sendFile(filename, offset);
return this;
}
Ask the OS to stream a file as specified by filename
directly
from disk to the outgoing connection, bypassing userspace altogether
(where supported by the underlying operating system.
This is a very efficient way to serve files.
The actual serve is asynchronous and may not complete until some time after this method has returned.
Params: - filename – path to the file to serve
- offset – offset to start serving from
- length – the number of bytes to send
Returns: a reference to this, so the API can be used fluently
/**
* Ask the OS to stream a file as specified by <code>filename</code> directly
* from disk to the outgoing connection, bypassing userspace altogether
* (where supported by the underlying operating system.
* This is a very efficient way to serve files.<p>
* The actual serve is asynchronous and may not complete until some time after this method has returned.
* @param filename path to the file to serve
* @param offset offset to start serving from
* @param length the number of bytes to send
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse sendFile(String filename, long offset, long length) {
delegate.sendFile(filename, offset, length);
return this;
}
Like sendFile
but providing a handler which will be notified once the file has been completely written to the wire. Params: - filename – path to the file to serve
- resultHandler – handler that will be called on completion
Returns: a reference to this, so the API can be used fluently
/**
* Like {@link io.vertx.reactivex.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 resultHandler handler that will be called on completion
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse sendFile(String filename, Handler<AsyncResult<Void>> resultHandler) {
delegate.sendFile(filename, resultHandler);
return this;
}
Like sendFile
but providing a handler which will be notified once the file has been completely written to the wire. Params: - filename – path to the file to serve
Returns: a reference to this, so the API can be used fluently
/**
* Like {@link io.vertx.reactivex.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 Completable rxSendFile(String filename) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
sendFile(filename, handler);
});
}
Like sendFile
but providing a handler which will be notified once the file has been completely written to the wire. Params: - filename – path to the file to serve
- offset – the offset to serve from
- resultHandler – handler that will be called on completion
Returns: a reference to this, so the API can be used fluently
/**
* Like {@link io.vertx.reactivex.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 resultHandler handler that will be called on completion
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse sendFile(String filename, long offset, Handler<AsyncResult<Void>> resultHandler) {
delegate.sendFile(filename, offset, resultHandler);
return this;
}
Like sendFile
but providing a handler which will be notified once the file has been completely written to the wire. Params: - filename – path to the file to serve
- offset – the offset to serve from
Returns: a reference to this, so the API can be used fluently
/**
* Like {@link io.vertx.reactivex.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 Completable rxSendFile(String filename, long offset) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
sendFile(filename, offset, handler);
});
}
Like sendFile
but providing a handler which will be notified once the file has been completely written to the wire. Params: - filename – path to the file to serve
- offset – the offset to serve from
- length – the length to serve to
- resultHandler – handler that will be called on completion
Returns: a reference to this, so the API can be used fluently
/**
* Like {@link io.vertx.reactivex.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 the length to serve to
* @param resultHandler handler that will be called on completion
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse sendFile(String filename, long offset, long length, Handler<AsyncResult<Void>> resultHandler) {
delegate.sendFile(filename, offset, length, resultHandler);
return this;
}
Like sendFile
but providing a handler which will be notified once the file has been completely written to the wire. Params: - filename – path to the file to serve
- offset – the offset to serve from
- length – the length to serve to
Returns: a reference to this, so the API can be used fluently
/**
* Like {@link io.vertx.reactivex.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 the length to serve to
* @return a reference to this, so the API can be used fluently
*/
public Completable rxSendFile(String filename, long offset, long length) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
sendFile(filename, offset, length, handler);
});
}
Close the underlying TCP connection corresponding to the request.
/**
* Close the underlying TCP connection corresponding to the request.
*/
public void close() {
delegate.close();
}
Returns: has the response already ended?
/**
* @return has the response already ended?
*/
public boolean ended() {
boolean ret = delegate.ended();
return ret;
}
Returns: has the underlying TCP connection corresponding to the request already been closed?
/**
* @return has the underlying TCP connection corresponding to the request already been closed?
*/
public boolean closed() {
boolean ret = delegate.closed();
return ret;
}
Returns: have the headers for the response already been written?
/**
* @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.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Provide a handler that will be called just before the headers are written to the wire.<p>
* 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.reactivex.core.http.HttpServerResponse headersEndHandler(Handler<Void> 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.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* 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.reactivex.core.http.HttpServerResponse bodyEndHandler(Handler<Void> handler) {
delegate.bodyEndHandler(handler);
return this;
}
Returns: the total number of bytes written for the body of the response.
/**
* @return the total number of bytes written for the body of the response.
*/
public long bytesWritten() {
long ret = delegate.bytesWritten();
return ret;
}
Returns: the id of the stream of this response, for HTTP/1.x
/**
* @return the id of the stream of this response, for HTTP/1.x
*/
public int streamId() {
int ret = delegate.streamId();
return ret;
}
Like push
with no headers. Params: - method –
- host –
- path –
- handler –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#push} with no headers.
* @param method
* @param host
* @param path
* @param handler
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse push(HttpMethod method, String host, String path, Handler<AsyncResult<io.vertx.reactivex.core.http.HttpServerResponse>> handler) {
delegate.push(method, host, path, new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() {
public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.http.HttpServerResponse.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
Like push
with no headers. Params: - method –
- host –
- path –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#push} with no headers.
* @param method
* @param host
* @param path
* @return
*/
public Single<io.vertx.reactivex.core.http.HttpServerResponse> rxPush(HttpMethod method, String host, String path) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
push(method, host, path, handler);
});
}
Like push
with the host copied from the current request. Params: - method –
- path –
- headers –
- handler –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#push} with the host copied from the current request.
* @param method
* @param path
* @param headers
* @param handler
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse push(HttpMethod method, String path, io.vertx.reactivex.core.MultiMap headers, Handler<AsyncResult<io.vertx.reactivex.core.http.HttpServerResponse>> handler) {
delegate.push(method, path, headers.getDelegate(), new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() {
public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.http.HttpServerResponse.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
Like push
with the host copied from the current request. Params: - method –
- path –
- headers –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#push} with the host copied from the current request.
* @param method
* @param path
* @param headers
* @return
*/
public Single<io.vertx.reactivex.core.http.HttpServerResponse> rxPush(HttpMethod method, String path, io.vertx.reactivex.core.MultiMap headers) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
push(method, path, headers, handler);
});
}
Like push
with the host copied from the current request. Params: - method –
- path –
- handler –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#push} with the host copied from the current request.
* @param method
* @param path
* @param handler
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse push(HttpMethod method, String path, Handler<AsyncResult<io.vertx.reactivex.core.http.HttpServerResponse>> handler) {
delegate.push(method, path, new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() {
public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.http.HttpServerResponse.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
Like push
with the host copied from the current request. Params: - method –
- path –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#push} with the host copied from the current request.
* @param method
* @param path
* @return
*/
public Single<io.vertx.reactivex.core.http.HttpServerResponse> rxPush(HttpMethod method, String path) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
push(method, path, handler);
});
}
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.
Params: - method – the method of the promised request
- host – the host of the promised request
- path – the path of the promised request
- headers – the headers of the promised request
- handler – the handler notified when the response can be written
Returns: a reference to this, so the API can be used fluently
/**
* Push a response to the client.<p/>
*
* The <code>handler</code> will be notified with a <i>success</i> when the push can be sent and with
* a <i>failure</i> when the client has disabled push or reset the push before it has been sent.<p/>
*
* The <code>handler</code> may be queued if the client has reduced the maximum number of streams the server can push
* concurrently.<p/>
*
* 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 the host of the promised request
* @param path the path of the promised request
* @param headers the headers of the promised request
* @param handler the handler notified when the response can be written
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpServerResponse push(HttpMethod method, String host, String path, io.vertx.reactivex.core.MultiMap headers, Handler<AsyncResult<io.vertx.reactivex.core.http.HttpServerResponse>> handler) {
delegate.push(method, host, path, headers.getDelegate(), new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() {
public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) {
if (ar.succeeded()) {
handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.http.HttpServerResponse.newInstance(ar.result())));
} else {
handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
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.
Params: - method – the method of the promised request
- host – the host of the promised request
- path – the path of the promised request
- headers – the headers of the promised request
Returns: a reference to this, so the API can be used fluently
/**
* Push a response to the client.<p/>
*
* The <code>handler</code> will be notified with a <i>success</i> when the push can be sent and with
* a <i>failure</i> when the client has disabled push or reset the push before it has been sent.<p/>
*
* The <code>handler</code> may be queued if the client has reduced the maximum number of streams the server can push
* concurrently.<p/>
*
* 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 the host of the promised request
* @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 Single<io.vertx.reactivex.core.http.HttpServerResponse> rxPush(HttpMethod method, String host, String path, io.vertx.reactivex.core.MultiMap headers) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
push(method, host, path, headers, handler);
});
}
Reset this HTTP/2 stream with the error code 0
.
/**
* Reset this HTTP/2 stream with the error code <code>0</code>.
*/
public void reset() {
delegate.reset();
}
Reset this HTTP/2 stream with the error code
.
Params: - code – the error code
/**
* Reset this HTTP/2 stream with the error <code>code</code>.
* @param code the error code
*/
public void reset(long code) {
delegate.reset(code);
}
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.
Params: - type – the 8-bit frame type
- flags – the 8-bit frame flags
- payload – the frame payload
Returns: a reference to this, so the API can be used fluently
/**
* Write an HTTP/2 frame to the response, allowing to extend the HTTP/2 protocol.<p>
*
* 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.reactivex.core.http.HttpServerResponse writeCustomFrame(int type, int flags, io.vertx.reactivex.core.buffer.Buffer payload) {
delegate.writeCustomFrame(type, flags, payload.getDelegate());
return this;
}
Like writeCustomFrame
but with an HttpFrame
. Params: - frame – the frame to write
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#writeCustomFrame} but with an {@link io.vertx.reactivex.core.http.HttpFrame}.
* @param frame the frame to write
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse writeCustomFrame(io.vertx.reactivex.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.
Params: - streamPriority – the priority for this request's stream
Returns:
/**
* Sets the priority of the associated stream
* <p/>
* This is not implemented for HTTP/1.x.
* @param streamPriority the priority for this request's stream
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse setStreamPriority(StreamPriority streamPriority) {
delegate.setStreamPriority(streamPriority);
return this;
}
Like putHeader
but using CharSequence Params: - name –
- value –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#putHeader} but using CharSequence
* @param name
* @param value
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse putHeader(CharSequence name, CharSequence value) {
delegate.putHeader(name, value);
return this;
}
Like putHeader
but providing multiple values via a String Iterable Params: - name –
- values –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#putHeader} but providing multiple values via a String Iterable
* @param name
* @param values
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse putHeader(String name, Iterable<String> values) {
delegate.putHeader(name, values);
return this;
}
Like putHeader
but with CharSequence Iterable Params: - name –
- values –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#putHeader} but with CharSequence Iterable
* @param name
* @param values
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse putHeader(CharSequence name, Iterable<CharSequence> values) {
delegate.putHeader(name, values);
return this;
}
Like putTrailer
but using CharSequence Params: - name –
- value –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#putTrailer} but using CharSequence
* @param name
* @param value
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse putTrailer(CharSequence name, CharSequence value) {
delegate.putTrailer(name, value);
return this;
}
Like putTrailer
but providing multiple values via a String Iterable Params: - name –
- values –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#putTrailer} but providing multiple values via a String Iterable
* @param name
* @param values
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse putTrailer(String name, Iterable<String> values) {
delegate.putTrailer(name, values);
return this;
}
Like putTrailer
but with CharSequence Iterable Params: - name –
- value –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpServerResponse#putTrailer} but with CharSequence Iterable
* @param name
* @param value
* @return
*/
public io.vertx.reactivex.core.http.HttpServerResponse putTrailer(CharSequence name, Iterable<CharSequence> value) {
delegate.putTrailer(name, value);
return this;
}
private io.vertx.reactivex.core.MultiMap cached_0;
private io.vertx.reactivex.core.MultiMap cached_1;
public static HttpServerResponse newInstance(io.vertx.core.http.HttpServerResponse arg) {
return arg != null ? new HttpServerResponse(arg) : null;
}
}