io.undertow.server

## Class Connectors

- java.lang.Object
- - io.undertow.server.Connectors

    public class Connectors
    extends Object

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
Constructor and Description
`Connectors()`

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static void` `addCookie(HttpServerExchange exchange, Cookie cookie)` Adds the cookie into the response header map.
`static boolean` `areRequestHeadersValid(HeaderMap headers)` Verifies that the provided request headers are valid according to rfc7230.
`static void` `executeRootHandler(HttpHandler handler, HttpServerExchange exchange)`
`static void` `flattenCookies(HttpServerExchange exchange)` Flattens the exchange cookie map into the response header map.
`static org.xnio.conduits.ConduitStreamSinkChannel` `getConduitSinkChannel(HttpServerExchange exchange)`
`static org.xnio.channels.StreamSourceChannel` `getExistingRequestChannel(HttpServerExchange exchange)` Returns the existing request channel, if it exists.
`static boolean` `isEntityBodyAllowed(HttpServerExchange exchange)`
`static boolean` `isEntityBodyAllowed(int code)`
`static boolean` `isValidSchemeCharacter(byte c)`
`static boolean` `isValidTokenCharacter(byte c)` Returns true if the token character is valid according to rfc7230
`static void` `resetRequestChannel(HttpServerExchange exchange)`
`static void` `setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean allowEncodedSlash, StringBuilder decodeBuffer)` Deprecated.
`static void` `setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, String charset, boolean decode, boolean allowEncodedSlash, StringBuilder decodeBuffer, int maxParameters)` Sets the request path and query parameters, decoding to the requested charset.
`static void` `setExchangeRequestPath(HttpServerExchange exchange, String encodedPath, StringBuilder decodeBuffer)` Sets the request path and query parameters, decoding to the requested charset.
`static void` `setRequestStartTime(HttpServerExchange exchange)`
`static void` `setRequestStartTime(HttpServerExchange existing, HttpServerExchange newExchange)`
`static void` `terminateRequest(HttpServerExchange exchange)`
`static void` `terminateResponse(HttpServerExchange exchange)`
`static void` `ungetRequestBytes(HttpServerExchange exchange, PooledByteBuffer... buffers)` Attached buffered data to the exchange.
`static void` `updateResponseBytesSent(HttpServerExchange exchange, long bytes)`
`static void` `verifyToken(HttpString header)` Verifies that the contents of the HttpString are a valid token according to rfc7230.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Connectors

    public Connectors()

### Method Detail

#### flattenCookies

    public static void flattenCookies(HttpServerExchange exchange)

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

    public static void addCookie(HttpServerExchange exchange,
                                 Cookie cookie)

Adds the cookie into the response header map. This should be called before the response is started.

Parameters:
  `exchange` - The server exchange
  `cookie` - The cookie

#### ungetRequestBytes

    public static void ungetRequestBytes(HttpServerExchange exchange,
                                         PooledByteBuffer... buffers)

Attached buffered data to the exchange. The will generally be used to allow data to be re-read.

Parameters:
  `exchange` - The HTTP server exchange
  `buffers` - The buffers to attach

#### terminateRequest

    public static void terminateRequest(HttpServerExchange exchange)

#### terminateResponse

    public static void terminateResponse(HttpServerExchange exchange)

#### resetRequestChannel

    public static void resetRequestChannel(HttpServerExchange exchange)

#### setRequestStartTime

    public static void setRequestStartTime(HttpServerExchange exchange)

#### setRequestStartTime

    public static void setRequestStartTime(HttpServerExchange existing,
                                           HttpServerExchange newExchange)

#### executeRootHandler

    public static void executeRootHandler(HttpHandler handler,
                                          HttpServerExchange exchange)

#### 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 exchange
  `encodedPath` - The encoded path
  `charset` - The charset

#### setExchangeRequestPath

    public static void setExchangeRequestPath(HttpServerExchange exchange,
                                              String encodedPath,
                                              StringBuilder decodeBuffer)
                                       throws ParameterLimitException

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 exchange
  `encodedPath` - The encoded path to decode
  `decodeBuffer` - The decode buffer to use
Throws:
  `ParameterLimitException`

#### setExchangeRequestPath

    public static void setExchangeRequestPath(HttpServerExchange exchange,
                                              String encodedPath,
                                              String charset,
                                              boolean decode,
                                              boolean allowEncodedSlash,
                                              StringBuilder decodeBuffer,
                                              int maxParameters)
                                       throws ParameterLimitException

Sets the request path and query parameters, decoding to the requested charset.

Parameters:
  `exchange` - The exchange
  `encodedPath` - The encoded path
  `charset` - The charset
Throws:
  `ParameterLimitException`

#### 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

    public static boolean isEntityBodyAllowed(HttpServerExchange exchange)

#### isEntityBodyAllowed

    public static boolean isEntityBodyAllowed(int code)

#### updateResponseBytesSent

    public static void updateResponseBytesSent(HttpServerExchange exchange,
                                               long bytes)

#### getConduitSinkChannel

    public static org.xnio.conduits.ConduitStreamSinkChannel getConduitSinkChannel(HttpServerExchange exchange)

#### verifyToken

    public static void verifyToken(HttpString header)

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

    public static boolean areRequestHeadersValid(HeaderMap headers)

Verifies that the provided request headers are valid according to rfc7230. In particular: - At most one content-length or transfer encoding