Package org.omegazero.http.util
Interface HTTPResponder
- All Known Subinterfaces:
HTTPServer
public interface HTTPResponder
- Since:
- 1.2.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]
A byte array with length zero. -
Method Summary
Modifier and TypeMethodDescriptionvoid
respond
(HTTPRequest request, int status, byte[] data, String... headers) Responds to the given request with a new HTTP response with the given status, data and headers, if the request has not already received a response.void
respond
(HTTPRequest request, HTTPResponseData response) Responds to the given request with the given response, if the request has not already received a response.
-
Field Details
-
EMPTY_BYTE_ARRAY
static final byte[] EMPTY_BYTE_ARRAYA byte array with length zero.- Since:
- 1.4.1
-
-
Method Details
-
respond
Responds to the given request with the given response, if the request has not already received a response.A responder may set additional, edit, or delete any headers in the HTTP response.
- Parameters:
request
- The request to respond toresponse
- The response- See Also:
-
respond
Responds to the given request with a new HTTP response with the given status, data and headers, if the request has not already received a response.In the headers array, each value at an even index (starting at 0) is a header key (name), followed by the values at odd indices. If the array length is not a multiple of 2, the last element is ignored. For example, an array like
{"x-example", "123", "x-another-header", "value here"}
will set two headers in the response with names "x-example" and "x-another-header" and values "123" and "value here", respectively.A responder may set additional, edit, or delete any headers in the HTTP response.
- Parameters:
request
- The request to respond tostatus
- The status code of the responsedata
- The data to send in the responseheaders
- Headers to send in the response. See explanation in description- See Also:
-