Interface WebResponse
- All Known Implementing Classes:
AbstractWebResponse, BlockingWebResponse, NettyWebResponse, NonBlockingWebResponse
public interface WebResponse
-
Method Summary
Modifier and TypeMethodDescriptionbooleanend()Completes the asynchronous operation that was started on the request.Returns the value of the specified response header as a String.Returns the internal object of this WebResponse.getProperty(String name) Returns the value to which the specified "name" is mapped, or null if this WebResponse contains no mapping for the "name".intGets the current status code of this response.voidsend(byte[] bytes) Writes b.length bytes of body from the specified byte array to the output stream.voidSets a response header with the given name and value.voidsetProperty(String name, Object value) Associates the specified value with the specified "name" in this WebResponse.voidsetStatus(int code) Sets the status code for this response.
-
Method Details
-
setStatus
void setStatus(int code) Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the 200 or 404 status codes). This method preserves any cookies and other response headers. Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container specific.- Parameters:
code- the status code
-
getStatus
int getStatus()Gets the current status code of this response.- Returns:
- the status code
-
setHeader
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one.- Parameters:
name- the name of the headervalue- the header value If it contains octet string, it should be encoded according to RFC 2047
-
getHeader
Returns the value of the specified response header as a String. If the response did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the response.- Parameters:
name- name a String specifying the header name- Returns:
- a String containing the value of the response header, or null if the response does not have a header of that name
-
send
Writes b.length bytes of body from the specified byte array to the output stream.- Parameters:
bytes- the data- Throws:
IOException- if an I/O error occurs
-
end
boolean end()Completes the asynchronous operation that was started on the request.- Returns:
- first call of this method returns with true
-
setProperty
Associates the specified value with the specified "name" in this WebResponse. If the WebResponse previously contained a mapping for the "name", the old value is replaced.- Parameters:
name- a "name" with which the specified value is to be associatedvalue- value to be associated with the specified "name"
-
getProperty
Returns the value to which the specified "name" is mapped, or null if this WebResponse contains no mapping for the "name".- Parameters:
name- the "name" whose associated value is to be returned- Returns:
- the value to which the specified "name" is mapped, or null if this WebResponse contains no mapping for the "name"
-
getInternalObject
Object getInternalObject()Returns the internal object of this WebResponse.- Returns:
- internal object (HttpServletResponse or Netty Context)
-