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 io. so it can be used with
io. to pipe data with flow control.
| Modifier and Type | Method and Description |
|---|---|
| public HttpServerResponse | |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe handler handler)Provides a handler that will be called after the last part of the body is written to the wire. |
| public long | |
| public void | close()
Deprecated
instead use
HttpConnection#close() or reset(long), this method is removed in Vert.x 5
Close the underlying TCP connection corresponding to the request. |
| public boolean | Returns: has the underlying TCP connection corresponding to the request already been closed?
|
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe handler 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. |
| public HttpServerResponse | |
| public Future | Returns: a future completed with the body resultthe string to write before ending the response chunk)Redeclares as abstract: io. Same as |
| public void | end(String chunk, Handler<AsyncResult<Void>> handler)
Redeclares as abstract: io. Same as |
| public Future | Returns: a future completed with the body resultthe string to write before ending the response chunk, String the encoding to use enc)Same as |
| public void | end(String chunk, String enc, Handler<AsyncResult<Void>> handler)
Same as |
| public Future | Returns: a future completed with the body resultthe buffer to write before ending the response chunk)Redeclares as abstract: io.
References Deprecated
Buffer is deprecated or references (maybe indirectly) at least one deprecated element.
Same as |
| public void | end(Buffer chunk, Handler<AsyncResult<Void>> handler)
Redeclares as abstract: io.
References Deprecated
Buffer is deprecated or references (maybe indirectly) at least one deprecated element.
Same as |
| public Future | Returns: a future completed with the body resultRedeclares as abstract: io. Ends the response. |
| public boolean | |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe handler handler)Set an end handler for the response. |
| public HttpServerResponse | |
| public int | |
| public String | Returns: the HTTP status message of the response. If this is not specified a default value will be used depending on whatsetStatusCode has been set to.
|
| public MultiMap | |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe handler handler)Provide a handler that will be called just before the headers are written to the wire. |
| public boolean | |
| public boolean | |
| public default HttpServerResponse | push(HttpMethod method, String host, String path, Handler<AsyncResult<HttpServerResponse>> handler)
Deprecated
instead use
push(HttpMethod, HostAndPort, String, Handler)
Like |
| public default Future | push(HttpMethod method, String host, String path)
Deprecated
instead use
push(HttpMethod, HostAndPort, String)
Same as |
| public default HttpServerResponse | push(HttpMethod method, HostAndPort host, String path, Handler<AsyncResult<HttpServerResponse>> handler)
Like |
| public default Future | push(HttpMethod method, HostAndPort host, String path)
Same as |
| public default HttpServerResponse | push(HttpMethod method, String path, MultiMap headers, Handler<AsyncResult<HttpServerResponse>> handler)
Like |
| public default Future | push(HttpMethod method, String path, MultiMap headers)
Same as |
| public default HttpServerResponse | push(HttpMethod method, String path, Handler<AsyncResult<HttpServerResponse>> handler)
Like |
| public default Future | push(HttpMethod method, String path)
Same as |
| public default HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe method of the promised request method, String the authority of the promised request host, String the path of the promised request path, MultiMap the headers of the promised request headers, Handler<AsyncResult<HttpServerResponse>> the handler notified when the response can be written handler)
Deprecated
Push a response to the client. |
| public Future | Returns: a future notified when the response can be writtenthe method of the promised request method, String the host of the promised request host, String the path of the promised request path, MultiMap the headers of the promised request headers)
Deprecated
instead use
push(HttpMethod, HostAndPort, String, MultiMap)
Push a response to the client. |
| public default HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe method of the promised request method, HostAndPort the authority of the promised request authority, String the path of the promised request path, MultiMap the headers of the promised request headers, Handler<AsyncResult<HttpServerResponse>> the handler notified when the response can be written handler)Push a response to the client. |
| public Future | push(HttpMethod method, HostAndPort authority, String path, MultiMap headers)
Same as |
| public HttpServerResponse | |
| public HttpServerResponse | putHeader(CharSequence name, CharSequence value)
Like |
| public HttpServerResponse | putHeader(String name, Iterable<String> values)
Like |
| public HttpServerResponse | putHeader(CharSequence name, Iterable<CharSequence> values)
Like |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe trailer name name, String the trailer value value)Put an HTTP trailer |
| public HttpServerResponse | putTrailer(CharSequence name, CharSequence value)
Like |
| public HttpServerResponse | putTrailer(String name, Iterable<String> values)
Like |
| public HttpServerResponse | putTrailer(CharSequence name, Iterable<CharSequence> value)
Like |
| public default @Nullable Cookie | Returns: the cookie, if it existed, or nullthe name of the cookie name)Expire a cookie, notifying a User Agent to remove it from its cookie jar. |
| public @Nullable Cookie | Returns: the cookie, if it existed, ornullthe name of the cookie name, boolean invalidate)Remove a cookie from the cookie set. |
| public default @Nullable Cookie | Returns: the cookie, if it existed, ornullthe name of the cookie name, String the domain of the cookie domain, String the path of the cookie path)Expires a cookie from the cookie set. |
| public @Nullable Cookie | Returns: the cookie, if it existed, ornullthe name of the cookie name, String the domain of the cookie domain, String the path of the cookie path, boolean invalidate)Remove a cookie from the cookie set. |
| public default Set | Returns: a read only set of affected cookies, if they existed, or an empty set.the name of the cookie name)Expire all cookies, notifying a User Agent to remove it from its cookie jar. |
| public Set | Returns: a read only set of affected cookies, if they existed, or an empty set.the name of the cookie name, boolean invalidate from the user agent invalidate)Remove all cookies from the cookie set. |
| public default boolean | |
| public boolean | Returns: true when reset has been performedthe error code code)Reset this response:
|
| public default void | |
| public default Future | |
| public default void | send(String body, Handler<AsyncResult<Void>>
the completion handler handler)Send the request with a string |
| public default Future | |
| public default void | |
| public default Future | send(Buffer body)
References Deprecated
Buffer is deprecated or references (maybe indirectly) at least one deprecated element.
Like |
| public default void | send(ReadStream<Buffer> body, Handler<AsyncResult<Void>>
the completion handler handler)Send the request with a stream |
| public default Future | send(ReadStream<Buffer> body)
Like |
| public default Future | Returns: a future completed with the body resultpath to the file to serve filename)Same as |
| public default Future | Returns: a future completed with the body resultpath to the file to serve filename, long offset to start serving from offset)Same as |
| public Future | Returns: a future completed with the body resultpath to the file to serve filename, long offset to start serving from offset, long the number of bytes to send length)Ask the OS to stream a file as specified by |
| public default HttpServerResponse | Returns: a reference to this, so the API can be used fluentlypath to the file to serve filename, Handler<AsyncResult<Void>> handler that will be called on completion resultHandler)Like |
| public default HttpServerResponse | Returns: a reference to this, so the API can be used fluentlypath to the file to serve filename, long the offset to serve from offset, Handler<AsyncResult<Void>> handler that will be called on completion resultHandler)Like |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlypath to the file to serve filename, long the offset to serve from offset, long length the number of bytes to send length, Handler<AsyncResult<Void>> handler that will be called on completion resultHandler)Like |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlyIf |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlySet the status code. |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlySet the status message |
| public default HttpServerResponse | setStreamPriority(StreamPriority
the priority for this request's stream streamPriority)Sets the priority of the associated stream This is not implemented for HTTP/1.x. |
| public HttpServerResponse | setWriteQueueMaxSize(int
the max size of the write stream maxSize)Redeclares io. Set the maximum size of the write queue to |
| public int | |
| public MultiMap | |
| public Future | |
| public void | write(String chunk, String enc, Handler<AsyncResult<Void>> handler)
Same as |
| public Future | Returns: a future completed with the body resultthe string to write chunk)Redeclares io. Write a |
| public void | write(String chunk, Handler<AsyncResult<Void>> handler)
Redeclares io. Same as |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlyUsed to write an interim 100 Continue response to signify that the client should send the rest of the request. |
| public HttpServerResponse | Returns: a reference to this, so the API can be used fluentlythe 8-bit frame type type, int the 8-bit frame flags flags, Buffer the frame payload payload)
References Deprecated
Buffer is deprecated or references (maybe indirectly) at least one deprecated element.
Write an HTTP/2 frame to the response, allowing to extend the HTTP/2 protocol. |
| public default HttpServerResponse | writeCustomFrame(HttpFrame
the frame to write frame)Like |
| public Future | Returns: a futureheaders to write headers)Used to write an interim 103 Early Hints response to return some HTTP headers before the final HTTP message. |
| public void | writeEarlyHints(MultiMap
headers to write headers, Handler<AsyncResult<Void>> handler)Same as |