Package org.omegazero.proxy.util
Interface HTTPEngineResponderMixin
- All Known Implementing Classes:
AbstractHTTPEngine
public interface HTTPEngineResponderMixin
A mixin containing utility methods for the
HTTPEngine respond methods.- Since:
- 3.6.1
-
Method Summary
Modifier and TypeMethodDescriptionorg.omegazero.net.socket.SocketConnectionReturns the HTTP version name string used for theHTTPMessageversionfield.voidrespond(org.omegazero.http.common.HTTPRequest request, org.omegazero.http.common.HTTPResponseData httpResponseData) default voidrespondError(Proxy proxy, org.omegazero.http.common.HTTPRequest request, int status, String title, String message, String... headers) Prepares an error response with the given parameters.default voidrespondEx(Proxy proxy, org.omegazero.http.common.HTTPRequest request, int status, byte[] data, String[] h1, String... h2) Responds to the given request with the given parameters.default voidrespondUNetError(Proxy proxy, org.omegazero.http.common.HTTPRequest request, int status, String message, org.omegazero.net.socket.SocketConnection uconn, UpstreamServer userver) Emits a HTTP_FORWARD_FAILED event on theProxyevent bus with the given parameters, and, if no response was sent, responds with an appropriate error message.
-
Method Details
-
getDownstreamConnection
org.omegazero.net.socket.SocketConnection getDownstreamConnection() -
respond
void respond(org.omegazero.http.common.HTTPRequest request, org.omegazero.http.common.HTTPResponseData httpResponseData) -
getHTTPVersionName
String getHTTPVersionName()Returns the HTTP version name string used for theHTTPMessageversionfield.- Returns:
- The HTTP version name
-
respondError
default void respondError(Proxy proxy, org.omegazero.http.common.HTTPRequest request, int status, String title, String message, String... headers) Prepares an error response with the given parameters.The
respondErrormethod can directly delegate to this method.- Parameters:
proxy- TheProxyinstancerequest- The request to respond tostatus- The status code of the responsetitle- Title of the error messagemessage- Error messageheaders- Headers to send in the response
-
respondUNetError
default void respondUNetError(Proxy proxy, org.omegazero.http.common.HTTPRequest request, int status, String message, org.omegazero.net.socket.SocketConnection uconn, UpstreamServer userver) Emits a HTTP_FORWARD_FAILED event on theProxyevent bus with the given parameters, and, if no response was sent, responds with an appropriate error message.This method is used when the HTTP request could not be completed due to a problem with the upstream server.
- Parameters:
proxy- TheProxyinstancerequest- The requeststatus- The response statusmessage- The response error messageuconn- The upstream connectionuserver- The upstream server
-
respondEx
default void respondEx(Proxy proxy, org.omegazero.http.common.HTTPRequest request, int status, byte[] data, String[] h1, String... h2) Responds to the given request with the given parameters.The
respondmethod can directly delegate to this method.- Parameters:
proxy- TheProxyinstancerequest- The request to respond tostatus- The status code of the responsedata- The data to send in the responseh1- The response headersh2- A second set of response headers
-