public class HttpServerResponse extends Object implements WriteStream<Buffer>
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.
original
non RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<HttpServerResponse> |
__TYPE_ARG |
Constructor and Description |
---|
HttpServerResponse(HttpServerResponse delegate) |
HttpServerResponse(Object delegate) |
Modifier and Type | Method and Description |
---|---|
HttpServerResponse |
addCookie(Cookie cookie)
Add a cookie.
|
HttpServerResponse |
bodyEndHandler(Handler<Void> handler)
Provides a handler that will be called after the last part of the body is written to the wire.
|
long |
bytesWritten() |
void |
close()
Close the underlying TCP connection corresponding to the request.
|
boolean |
closed() |
HttpServerResponse |
closeHandler(Handler<Void> handler)
Set a close handler for the response, this is called when the underlying connection is closed and the response
was still using the connection.
|
HttpServerResponse |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
Ends the response.
|
void |
end(Buffer chunk)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but writes some data to the response body before ending. |
void |
end(Buffer chunk,
Handler<AsyncResult<Void>> handler)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
end(Handler<AsyncResult<Void>> handler)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
end(String chunk)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but writes a String in UTF-8 encoding before ending the response. |
void |
end(String chunk,
Handler<AsyncResult<Void>> handler)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
end(String chunk,
String enc)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but writes a String with the specified encoding before ending the response. |
void |
end(String chunk,
String enc,
Handler<AsyncResult<Void>> handler)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
boolean |
ended() |
HttpServerResponse |
endHandler(Handler<Void> handler)
Set an end handler for the response.
|
Observable<Void> |
endObservable()
Deprecated.
use
rxEnd() instead |
Observable<Void> |
endObservable(Buffer chunk)
Deprecated.
use
rxEnd() instead |
Observable<Void> |
endObservable(String chunk)
Deprecated.
use
rxEnd() instead |
Observable<Void> |
endObservable(String chunk,
String enc)
Deprecated.
use
rxEnd() instead |
boolean |
equals(Object o) |
HttpServerResponse |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
HttpServerResponse |
getDelegate() |
int |
getStatusCode() |
String |
getStatusMessage() |
int |
hashCode() |
MultiMap |
headers() |
HttpServerResponse |
headersEndHandler(Handler<Void> handler)
Provide a handler that will be called just before the headers are written to the wire.
|
boolean |
headWritten() |
boolean |
isChunked() |
static HttpServerResponse |
newInstance(HttpServerResponse arg) |
HttpServerResponse |
push(HttpMethod method,
String path,
Handler<AsyncResult<HttpServerResponse>> handler)
Like
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>) with the host copied from the current request. |
HttpServerResponse |
push(HttpMethod method,
String path,
MultiMap headers,
Handler<AsyncResult<HttpServerResponse>> handler)
Like
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>) with the host copied from the current request. |
HttpServerResponse |
push(HttpMethod method,
String host,
String path,
Handler<AsyncResult<HttpServerResponse>> handler)
|
HttpServerResponse |
push(HttpMethod method,
String host,
String path,
MultiMap headers,
Handler<AsyncResult<HttpServerResponse>> 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. |
Observable<HttpServerResponse> |
pushObservable(HttpMethod method,
String path)
Deprecated.
|
Observable<HttpServerResponse> |
pushObservable(HttpMethod method,
String path,
MultiMap headers)
Deprecated.
|
Observable<HttpServerResponse> |
pushObservable(HttpMethod method,
String host,
String path)
Deprecated.
|
Observable<HttpServerResponse> |
pushObservable(HttpMethod method,
String host,
String path,
MultiMap headers)
Deprecated.
|
HttpServerResponse |
putHeader(CharSequence name,
CharSequence value)
Like
putHeader(java.lang.String, java.lang.String) but using CharSequence |
HttpServerResponse |
putHeader(CharSequence name,
Iterable<CharSequence> values)
Like
putHeader(java.lang.String, java.lang.String) but with CharSequence Iterable |
HttpServerResponse |
putHeader(String name,
Iterable<String> values)
Like
putHeader(java.lang.String, java.lang.String) but providing multiple values via a String Iterable |
HttpServerResponse |
putHeader(String name,
String value)
Put an HTTP header
|
HttpServerResponse |
putTrailer(CharSequence name,
CharSequence value)
Like
putTrailer(java.lang.String, java.lang.String) but using CharSequence |
HttpServerResponse |
putTrailer(CharSequence name,
Iterable<CharSequence> value)
Like
putTrailer(java.lang.String, java.lang.String) but with CharSequence Iterable |
HttpServerResponse |
putTrailer(String name,
Iterable<String> values)
Like
putTrailer(java.lang.String, java.lang.String) but providing multiple values via a String Iterable |
HttpServerResponse |
putTrailer(String name,
String value)
Put an HTTP trailer
|
Cookie |
removeCookie(String name)
Expire a cookie, notifying a User Agent to remove it from its cookie jar.
|
Cookie |
removeCookie(String name,
boolean invalidate)
Remove a cookie from the cookie set.
|
void |
reset()
Reset this HTTP/2 stream with the error code
0 . |
void |
reset(long code)
Reset this HTTP/2 stream with the error
code . |
Single<Void> |
rxEnd()
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Single<Void> |
rxEnd(Buffer chunk)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Single<Void> |
rxEnd(String chunk)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Single<Void> |
rxEnd(String chunk,
String enc)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Single<HttpServerResponse> |
rxPush(HttpMethod method,
String path)
Like
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>) with the host copied from the current request. |
Single<HttpServerResponse> |
rxPush(HttpMethod method,
String path,
MultiMap headers)
Like
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>) with the host copied from the current request. |
Single<HttpServerResponse> |
rxPush(HttpMethod method,
String host,
String path)
|
Single<HttpServerResponse> |
rxPush(HttpMethod method,
String host,
String path,
MultiMap headers)
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. |
Single<Void> |
rxSendFile(String filename)
Like
sendFile(java.lang.String) but providing a handler which will be notified once the file has been completely
written to the wire. |
Single<Void> |
rxSendFile(String filename,
long offset)
Like
sendFile(java.lang.String) but providing a handler which will be notified once the file has been completely
written to the wire. |
Single<Void> |
rxSendFile(String filename,
long offset,
long length)
Like
sendFile(java.lang.String) but providing a handler which will be notified once the file has been
completely written to the wire. |
Single<Void> |
rxWrite(Buffer data)
Same as
write(io.vertx.rxjava.core.buffer.Buffer) but with an handler called when the operation completes |
Single<Void> |
rxWrite(String chunk)
Same as
write(io.vertx.rxjava.core.buffer.Buffer) but with an handler called when the operation completes |
Single<Void> |
rxWrite(String chunk,
String enc)
Same as
write(io.vertx.rxjava.core.buffer.Buffer) but with an handler called when the operation completes |
HttpServerResponse |
sendFile(String filename)
Same as
sendFile(java.lang.String) using offset @code{0} which means starting from the beginning of the file. |
HttpServerResponse |
sendFile(String filename,
Handler<AsyncResult<Void>> resultHandler)
Like
sendFile(java.lang.String) but providing a handler which will be notified once the file has been completely
written to the wire. |
HttpServerResponse |
sendFile(String filename,
long offset)
Same as
sendFile(java.lang.String) using length @code{Long.MAX_VALUE} which means until the end of the
file. |
HttpServerResponse |
sendFile(String filename,
long offset,
Handler<AsyncResult<Void>> resultHandler)
Like
sendFile(java.lang.String) but providing a handler which will be notified once the file has been completely
written to the wire. |
HttpServerResponse |
sendFile(String filename,
long offset,
long length)
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. |
HttpServerResponse |
sendFile(String filename,
long offset,
long length,
Handler<AsyncResult<Void>> resultHandler)
Like
sendFile(java.lang.String) but providing a handler which will be notified once the file has been
completely written to the wire. |
Observable<Void> |
sendFileObservable(String filename)
Deprecated.
use
rxSendFile(java.lang.String) instead |
Observable<Void> |
sendFileObservable(String filename,
long offset)
Deprecated.
use
rxSendFile(java.lang.String) instead |
Observable<Void> |
sendFileObservable(String filename,
long offset,
long length)
Deprecated.
use
rxSendFile(java.lang.String) instead |
HttpServerResponse |
setChunked(boolean chunked)
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. |
HttpServerResponse |
setStatusCode(int statusCode)
Set the status code.
|
HttpServerResponse |
setStatusMessage(String statusMessage)
Set the status message
|
HttpServerResponse |
setStreamPriority(StreamPriority streamPriority)
Sets the priority of the associated stream
This is not implemented for HTTP/1.x.
|
HttpServerResponse |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
int |
streamId() |
String |
toString() |
io.vertx.rx.java.WriteStreamSubscriber<Buffer> |
toSubscriber() |
MultiMap |
trailers() |
HttpServerResponse |
write(Buffer data)
Write some data to the stream.
|
HttpServerResponse |
write(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as
write(io.vertx.rxjava.core.buffer.Buffer) but with an handler called when the operation completes |
HttpServerResponse |
write(String chunk)
Write a
String to the response body, encoded in UTF-8. |
HttpServerResponse |
write(String chunk,
Handler<AsyncResult<Void>> handler)
Same as
write(io.vertx.rxjava.core.buffer.Buffer) but with an handler called when the operation completes |
HttpServerResponse |
write(String chunk,
String enc)
Write a
String to the response body, encoded using the encoding enc . |
HttpServerResponse |
write(String chunk,
String enc,
Handler<AsyncResult<Void>> handler)
Same as
write(io.vertx.rxjava.core.buffer.Buffer) but with an handler called when the operation completes |
HttpServerResponse |
writeContinue()
Used to write an interim 100 Continue response to signify that the client should send the rest of the request.
|
HttpServerResponse |
writeCustomFrame(HttpFrame frame)
Like
writeCustomFrame(int, int, io.vertx.rxjava.core.buffer.Buffer) but with an HttpFrame . |
HttpServerResponse |
writeCustomFrame(int type,
int flags,
Buffer payload)
Write an HTTP/2 frame to the response, allowing to extend the HTTP/2 protocol.
|
Observable<Void> |
writeObservable(Buffer data)
Deprecated.
use
rxWrite(io.vertx.rxjava.core.buffer.Buffer) instead |
Observable<Void> |
writeObservable(String chunk)
Deprecated.
use
rxWrite(io.vertx.rxjava.core.buffer.Buffer) instead |
Observable<Void> |
writeObservable(String chunk,
String enc)
Deprecated.
use
rxWrite(io.vertx.rxjava.core.buffer.Buffer) instead |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance, newInstance
newInstance
public static final io.vertx.lang.rx.TypeArg<HttpServerResponse> __TYPE_ARG
public HttpServerResponse(HttpServerResponse delegate)
public HttpServerResponse(Object delegate)
public HttpServerResponse getDelegate()
getDelegate
in interface StreamBase
getDelegate
in interface WriteStream<Buffer>
public io.vertx.rx.java.WriteStreamSubscriber<Buffer> toSubscriber()
public void end(Handler<AsyncResult<Void>> handler)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesend
in interface WriteStream<Buffer>
handler
- @Deprecated public Observable<Void> endObservable()
rxEnd()
insteadend(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completespublic Single<Void> rxEnd()
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completespublic boolean writeQueueFull()
true
if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int)
writeQueueFull
in interface WriteStream<Buffer>
public HttpServerResponse exceptionHandler(Handler<Throwable> handler)
WriteStream
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<Buffer>
handler
- the exception handlerpublic HttpServerResponse write(Buffer data)
WriteStream
WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.write
in interface WriteStream<Buffer>
data
- the data to writepublic HttpServerResponse write(Buffer data, Handler<AsyncResult<Void>> handler)
write(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeswrite
in interface WriteStream<Buffer>
data
- handler
- @Deprecated public Observable<Void> writeObservable(Buffer data)
rxWrite(io.vertx.rxjava.core.buffer.Buffer)
insteadwrite(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completesdata
- public Single<Void> rxWrite(Buffer data)
write(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completesdata
- public HttpServerResponse setWriteQueueMaxSize(int maxSize)
WriteStream
maxSize
. You will still be able to write to the stream even
if there is more than maxSize
items in the write queue. This is used as an indicator by classes such as
Pump
to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket
, the number of Message
for a
MessageProducer
, etc...setWriteQueueMaxSize
in interface WriteStream<Buffer>
maxSize
- the max size of the write streampublic HttpServerResponse drainHandler(Handler<Void> handler)
WriteStream
Pump
for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been
reduced to maxSize / 2
.drainHandler
in interface WriteStream<Buffer>
handler
- the handlerpublic int getStatusCode()
200
representing OK
.public HttpServerResponse setStatusCode(int statusCode)
statusCode
- public String getStatusMessage()
setStatusCode(int)
has been set to.public HttpServerResponse setStatusMessage(String statusMessage)
statusMessage
- public HttpServerResponse setChunked(boolean chunked)
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.
chunked
- public boolean isChunked()
public MultiMap headers()
public HttpServerResponse putHeader(String name, String value)
name
- the header namevalue
- the header value.public MultiMap trailers()
public HttpServerResponse putTrailer(String name, String value)
name
- the trailer namevalue
- the trailer valuepublic HttpServerResponse closeHandler(Handler<Void> handler)
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.
handler
- the handlerpublic HttpServerResponse endHandler(Handler<Void> handler)
handler
- the handlerpublic HttpServerResponse write(String chunk, String enc)
String
to the response body, encoded using the encoding enc
.chunk
- the string to writeenc
- the encoding to usepublic HttpServerResponse write(String chunk, String enc, Handler<AsyncResult<Void>> handler)
write(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeschunk
- enc
- handler
- @Deprecated public Observable<Void> writeObservable(String chunk, String enc)
rxWrite(io.vertx.rxjava.core.buffer.Buffer)
insteadwrite(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeschunk
- enc
- public Single<Void> rxWrite(String chunk, String enc)
write(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeschunk
- enc
- public HttpServerResponse write(String chunk)
String
to the response body, encoded in UTF-8.chunk
- the string to writepublic HttpServerResponse write(String chunk, Handler<AsyncResult<Void>> handler)
write(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeschunk
- handler
- @Deprecated public Observable<Void> writeObservable(String chunk)
rxWrite(io.vertx.rxjava.core.buffer.Buffer)
insteadwrite(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeschunk
- public Single<Void> rxWrite(String chunk)
write(io.vertx.rxjava.core.buffer.Buffer)
but with an handler
called when the operation completeschunk
- public HttpServerResponse writeContinue()
public void end(String chunk)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but writes a String in UTF-8 encoding before ending the response.chunk
- the string to write before ending the responsepublic void end(String chunk, Handler<AsyncResult<Void>> handler)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- handler
- @Deprecated public Observable<Void> endObservable(String chunk)
rxEnd()
insteadend(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- public Single<Void> rxEnd(String chunk)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- public void end(String chunk, String enc)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but writes a String with the specified encoding before ending the response.chunk
- the string to write before ending the responseenc
- the encoding to usepublic void end(String chunk, String enc, Handler<AsyncResult<Void>> handler)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- enc
- handler
- @Deprecated public Observable<Void> endObservable(String chunk, String enc)
rxEnd()
insteadend(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- enc
- public Single<Void> rxEnd(String chunk, String enc)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- enc
- public void end(Buffer chunk)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
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.end
in interface WriteStream<Buffer>
chunk
- the buffer to write before ending the responsepublic void end(Buffer chunk, Handler<AsyncResult<Void>> handler)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesend
in interface WriteStream<Buffer>
chunk
- handler
- @Deprecated public Observable<Void> endObservable(Buffer chunk)
rxEnd()
insteadend(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- public Single<Void> rxEnd(Buffer chunk)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeschunk
- public void end()
Once the response has ended, it cannot be used any more.
end
in interface WriteStream<Buffer>
public HttpServerResponse sendFile(String filename)
sendFile(java.lang.String)
using offset @code{0} which means starting from the beginning of the file.filename
- path to the file to servepublic HttpServerResponse sendFile(String filename, long offset)
sendFile(java.lang.String)
using length @code{Long.MAX_VALUE} which means until the end of the
file.filename
- path to the file to serveoffset
- offset to start serving frompublic HttpServerResponse sendFile(String filename, long offset, long length)
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.
filename
- path to the file to serveoffset
- offset to start serving fromlength
- the number of bytes to sendpublic HttpServerResponse sendFile(String filename, Handler<AsyncResult<Void>> resultHandler)
sendFile(java.lang.String)
but providing a handler which will be notified once the file has been completely
written to the wire.filename
- path to the file to serveresultHandler
- handler that will be called on completion@Deprecated public Observable<Void> sendFileObservable(String filename)
rxSendFile(java.lang.String)
insteadsendFile(java.lang.String)
but providing a handler which will be notified once the file has been completely
written to the wire.filename
- path to the file to servepublic Single<Void> rxSendFile(String filename)
sendFile(java.lang.String)
but providing a handler which will be notified once the file has been completely
written to the wire.filename
- path to the file to servepublic HttpServerResponse sendFile(String filename, long offset, Handler<AsyncResult<Void>> resultHandler)
sendFile(java.lang.String)
but providing a handler which will be notified once the file has been completely
written to the wire.filename
- path to the file to serveoffset
- the offset to serve fromresultHandler
- handler that will be called on completion@Deprecated public Observable<Void> sendFileObservable(String filename, long offset)
rxSendFile(java.lang.String)
insteadsendFile(java.lang.String)
but providing a handler which will be notified once the file has been completely
written to the wire.filename
- path to the file to serveoffset
- the offset to serve frompublic Single<Void> rxSendFile(String filename, long offset)
sendFile(java.lang.String)
but providing a handler which will be notified once the file has been completely
written to the wire.filename
- path to the file to serveoffset
- the offset to serve frompublic HttpServerResponse sendFile(String filename, long offset, long length, Handler<AsyncResult<Void>> resultHandler)
sendFile(java.lang.String)
but providing a handler which will be notified once the file has been
completely written to the wire.filename
- path to the file to serveoffset
- the offset to serve fromlength
- the length to serve toresultHandler
- handler that will be called on completion@Deprecated public Observable<Void> sendFileObservable(String filename, long offset, long length)
rxSendFile(java.lang.String)
insteadsendFile(java.lang.String)
but providing a handler which will be notified once the file has been
completely written to the wire.filename
- path to the file to serveoffset
- the offset to serve fromlength
- the length to serve topublic Single<Void> rxSendFile(String filename, long offset, long length)
sendFile(java.lang.String)
but providing a handler which will be notified once the file has been
completely written to the wire.filename
- path to the file to serveoffset
- the offset to serve fromlength
- the length to serve topublic void close()
public boolean ended()
public boolean closed()
public boolean headWritten()
public HttpServerResponse headersEndHandler(Handler<Void> handler)
This provides a hook allowing you to add any more headers or do any more operations before this occurs.
handler
- the handlerpublic HttpServerResponse bodyEndHandler(Handler<Void> handler)
handler
- the handlerpublic long bytesWritten()
public int streamId()
public HttpServerResponse push(HttpMethod method, String host, String path, Handler<AsyncResult<HttpServerResponse>> handler)
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with no headers.method
- host
- path
- handler
- @Deprecated public Observable<HttpServerResponse> pushObservable(HttpMethod method, String host, String path)
rxPush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)
insteadpush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with no headers.method
- host
- path
- public Single<HttpServerResponse> rxPush(HttpMethod method, String host, String path)
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with no headers.method
- host
- path
- public HttpServerResponse push(HttpMethod method, String path, MultiMap headers, Handler<AsyncResult<HttpServerResponse>> handler)
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with the host copied from the current request.method
- path
- headers
- handler
- @Deprecated public Observable<HttpServerResponse> pushObservable(HttpMethod method, String path, MultiMap headers)
rxPush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)
insteadpush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with the host copied from the current request.method
- path
- headers
- public Single<HttpServerResponse> rxPush(HttpMethod method, String path, MultiMap headers)
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with the host copied from the current request.method
- path
- headers
- public HttpServerResponse push(HttpMethod method, String path, Handler<AsyncResult<HttpServerResponse>> handler)
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with the host copied from the current request.method
- path
- handler
- @Deprecated public Observable<HttpServerResponse> pushObservable(HttpMethod method, String path)
rxPush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)
insteadpush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with the host copied from the current request.method
- path
- public Single<HttpServerResponse> rxPush(HttpMethod method, String path)
push(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>>)
with the host copied from the current request.method
- path
- public HttpServerResponse push(HttpMethod method, String host, String path, MultiMap headers, Handler<AsyncResult<HttpServerResponse>> handler)
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.method
- the method of the promised requesthost
- the host of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised requesthandler
- the handler notified when the response can be written@Deprecated public Observable<HttpServerResponse> pushObservable(HttpMethod method, String host, String path, MultiMap headers)
rxPush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)
insteadhandler
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.method
- the method of the promised requesthost
- the host of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised requestpublic Single<HttpServerResponse> rxPush(HttpMethod method, String host, String path, MultiMap headers)
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.method
- the method of the promised requesthost
- the host of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised requestpublic void reset()
0
.public void reset(long code)
code
.code
- the error codepublic HttpServerResponse writeCustomFrame(int type, int flags, Buffer payload)
The frame is sent immediatly and is not subject to flow control.
type
- the 8-bit frame typeflags
- the 8-bit frame flagspayload
- the frame payloadpublic HttpServerResponse writeCustomFrame(HttpFrame frame)
writeCustomFrame(int, int, io.vertx.rxjava.core.buffer.Buffer)
but with an HttpFrame
.frame
- the frame to writepublic HttpServerResponse setStreamPriority(StreamPriority streamPriority)
streamPriority
- the priority for this request's streampublic HttpServerResponse addCookie(Cookie cookie)
cookie
- the cookiepublic Cookie removeCookie(String name)
name
- the name of the cookiepublic Cookie removeCookie(String name, boolean invalidate)
name
- the name of the cookieinvalidate
- public HttpServerResponse putHeader(CharSequence name, CharSequence value)
putHeader(java.lang.String, java.lang.String)
but using CharSequencename
- value
- public HttpServerResponse putHeader(String name, Iterable<String> values)
putHeader(java.lang.String, java.lang.String)
but providing multiple values via a String Iterablename
- values
- public HttpServerResponse putHeader(CharSequence name, Iterable<CharSequence> values)
putHeader(java.lang.String, java.lang.String)
but with CharSequence Iterablename
- values
- public HttpServerResponse putTrailer(CharSequence name, CharSequence value)
putTrailer(java.lang.String, java.lang.String)
but using CharSequencename
- value
- public HttpServerResponse putTrailer(String name, Iterable<String> values)
putTrailer(java.lang.String, java.lang.String)
but providing multiple values via a String Iterablename
- values
- public HttpServerResponse putTrailer(CharSequence name, Iterable<CharSequence> value)
putTrailer(java.lang.String, java.lang.String)
but with CharSequence Iterablename
- value
- public static HttpServerResponse newInstance(HttpServerResponse arg)
Copyright © 2023 Eclipse. All rights reserved.