Package io.undertow.server
Class Connectors
java.lang.Object
io.undertow.server.Connectors
This class provides the connector part of the
HttpServerExchange API.
It contains methods that logically belong on the exchange, however should only be used by connector implementations.
- Author:
- Stuart Douglas, Richard Opalka
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCookie(HttpServerExchange exchange, Cookie cookie) Adds the cookie into the response header map.static booleanareRequestHeadersValid(HeaderMap headers) Verifies that the provided request headers are valid according to rfc7230.static voidexecuteRootHandler(HttpHandler handler, HttpServerExchange exchange) static voidflattenCookies(HttpServerExchange exchange) Flattens the exchange cookie map into the response header map.static org.xnio.conduits.ConduitStreamSinkChannelgetConduitSinkChannel(HttpServerExchange exchange) static org.xnio.channels.StreamSourceChannelgetExistingRequestChannel(HttpServerExchange exchange) Returns the existing request channel, if it exists.static booleanisEntityBodyAllowed(int code) static booleanisEntityBodyAllowed(HttpServerExchange exchange) static booleanisValidSchemeCharacter(byte c) static booleanisValidTokenCharacter(byte c) Returns true if the token character is valid according to rfc7230static voidresetRequestChannel(HttpServerExchange exchange) static voidsetExchangeRequestPath(HttpServerExchange exchange, String encodedPath, StringBuilder decodeBuffer) Sets the request path and query parameters, decoding to the requested charset.static voidsetExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean decodeQueryString, boolean decodeSlashFlag, StringBuilder decodeBuffer, int maxParameters) Sets the request path and query parameters, decoding to the requested charset.static voidsetExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean allowEncodedSlash, StringBuilder decodeBuffer) Deprecated.static voidsetExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean decodeSlashFlag, StringBuilder decodeBuffer, int maxParameters) Sets the request path and query parameters, decoding to the requested charset.static voidsetRequestStartTime(HttpServerExchange exchange) static voidsetRequestStartTime(HttpServerExchange existing, HttpServerExchange newExchange) static voidterminateRequest(HttpServerExchange exchange) static voidterminateResponse(HttpServerExchange exchange) static voidungetRequestBytes(HttpServerExchange exchange, PooledByteBuffer... buffers) Attached buffered data to the exchange.static voidupdateResponseBytesSent(HttpServerExchange exchange, long bytes) static voidverifyToken(HttpString header) Verifies that the contents of the HttpString are a valid token according to rfc7230.
-
Constructor Details
-
Connectors
public Connectors()
-
-
Method Details
-
flattenCookies
Flattens the exchange cookie map into the response header map. This should be called by a connector just before the response is started.- Parameters:
exchange- The server exchange
-
addCookie
Adds the cookie into the response header map. This should be called before the response is started.- Parameters:
exchange- The server exchangecookie- The cookie
-
ungetRequestBytes
Attached buffered data to the exchange. The will generally be used to allow data to be re-read.- Parameters:
exchange- The HTTP server exchangebuffers- The buffers to attach
-
terminateRequest
-
terminateResponse
-
resetRequestChannel
-
setRequestStartTime
-
setRequestStartTime
-
executeRootHandler
-
setExchangeRequestPath
@Deprecated public static void setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean allowEncodedSlash, StringBuilder decodeBuffer) Deprecated.Sets the request path and query parameters, decoding to the requested charset.- Parameters:
exchange- The exchangeencodedPath- The encoded pathcharset- The charset
-
setExchangeRequestPath
public static void setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, StringBuilder decodeBuffer) throws ParameterLimitException, BadRequestException Sets the request path and query parameters, decoding to the requested charset. All the options are retrieved from the exchange undertow options.- Parameters:
exchange- The exchangeencodedPath- The encoded path to decodedecodeBuffer- The decode buffer to use- Throws:
ParameterLimitExceptionBadRequestException
-
setExchangeRequestPath
public static void setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean decodeSlashFlag, StringBuilder decodeBuffer, int maxParameters) throws ParameterLimitException, BadRequestException Sets the request path and query parameters, decoding to the requested charset.- Parameters:
exchange- the exchangeencodedPath- the encoded pathdecode- indicates if the request path should be decodeddecodeSlashFlag- indicates if slash characters contained in the encoded path should be decodeddecodeBuffer- the buffer used for decodingmaxParameters- maximum number of parameters allowed in the pathcharset- the charset- Throws:
BadRequestException- if there is something wrong with the request, such as non-allowed charactersParameterLimitException
-
setExchangeRequestPath
public static void setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean decodeQueryString, boolean decodeSlashFlag, StringBuilder decodeBuffer, int maxParameters) throws ParameterLimitException, BadRequestException Sets the request path and query parameters, decoding to the requested charset.- Parameters:
exchange- the exchangeencodedPath- the encoded pathdecode- indicates if the request path should be decoded, apart from the query string part of the request (see next parameter)decodeQueryString- indicates if the query string of the path, when present, should be decodeddecodeSlashFlag- indicates if slash characters contained in the request path should be decodeddecodeBuffer- the buffer used for decodingmaxParameters- maximum number of parameters allowed in the pathcharset- the charset- Throws:
BadRequestException- if there is something wrong with the request, such as non-allowed charactersParameterLimitException
-
getExistingRequestChannel
public static org.xnio.channels.StreamSourceChannel getExistingRequestChannel(HttpServerExchange exchange) Returns the existing request channel, if it exists. Otherwise returns null- Parameters:
exchange- The http server exchange
-
isEntityBodyAllowed
-
isEntityBodyAllowed
public static boolean isEntityBodyAllowed(int code) -
updateResponseBytesSent
-
getConduitSinkChannel
public static org.xnio.conduits.ConduitStreamSinkChannel getConduitSinkChannel(HttpServerExchange exchange) -
verifyToken
Verifies that the contents of the HttpString are a valid token according to rfc7230.- Parameters:
header- The header to verify
-
isValidTokenCharacter
public static boolean isValidTokenCharacter(byte c) Returns true if the token character is valid according to rfc7230 -
isValidSchemeCharacter
public static boolean isValidSchemeCharacter(byte c) -
areRequestHeadersValid
Verifies that the provided request headers are valid according to rfc7230. In particular: - At most one content-length or transfer encoding
-