Package io.fusionauth.http.server
Interface Configurable<T extends Configurable<T>>
- Type Parameters:
T- The type of configurable for casting.
- All Known Implementing Classes:
HTTPServer,HTTPServerConfiguration
public interface Configurable<T extends Configurable<T>>
An interface that identifies something that is configurable. Mainly, this allows the HTTPServer to be configured or to be passed a
configuration.
-
Method Summary
Modifier and TypeMethodDescriptiondefault TwithBaseDir(Path baseDir) Sets the base directory for this server.default TwithCompressByDefault(boolean compressByDefault) Sets the default compression behavior for the HTTP response.default TwithContextPath(String contextPath) Sets the prefix of the URIs that this server handles.default TwithExpectValidator(ExpectValidator validator) Sets an ExpectValidator that is used if a client sends the server aExpect: 100-continueheader.default TwithHandler(HTTPHandler handler) Sets the handler that will process the requests.default TwithInitialReadTimeout(Duration duration) Sets the duration that the server will attempt to read the first byte from a client.default TwithInstrumenter(Instrumenter instrumenter) Sets an instrumenter that the server will notify when events and conditions happen.default TwithKeepAliveTimeoutDuration(Duration duration) Sets the duration that the server will allow client connections to remain open and idle after each request has been processed.default TwithListener(HTTPListenerConfiguration listener) Adds a listener configuration for the server.default TwithLoggerFactory(LoggerFactory loggerFactory) Sets the logger factory that all the HTTP server classes use to retrieve specific loggers.default TwithMaxResponseChunkSize(int size) This configures the maximum size of a chunk in the response when the server is using chunked response encoding.default TwithMinimumReadThroughput(long bytesPerSecond) This configures the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.default TwithMinimumWriteThroughput(long bytesPerSecond) This configures the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.default TwithMultipartBufferSize(int multipartBufferSize) Sets the size of the buffer that is used to process the multipart request body.default TwithProcessingTimeoutDuration(Duration duration) Sets the duration that the server will allow worker threads to run after the final request byte is read and before the first response byte is written.default TThis configures the duration of the initial delay before calculating and enforcing the minimum read throughput.default TwithRequestBufferSize(int requestBufferSize) Sets the size of the buffer that is used to process the HTTP request.default TwithResponseBufferSize(int responseBufferSize) Sets the size of the buffer that is used to store the HTTP response before any bytes are written back to the client.default TwithShutdownDuration(Duration duration) Sets the duration the server will wait for running requests to be completed.default TThis configures the duration of the initial delay before calculating and enforcing the minimum write throughput.
-
Method Details
-
configuration
HTTPServerConfiguration configuration()- Returns:
- The configuration object.
-
withBaseDir
Sets the base directory for this server. This is passed to the HTTPContext, which is available from this class. This defaults to the current working directory of the process.- Parameters:
baseDir- The base dir.- Returns:
- This.
-
withCompressByDefault
Sets the default compression behavior for the HTTP response. This behavior can be optionally set per response. SeeHTTPResponse.setCompress(boolean). Defaults to true.- Parameters:
compressByDefault- true if you want to compress by default, or false to not compress by default.- Returns:
- This.
-
withContextPath
Sets the prefix of the URIs that this server handles. Technically, the server will accept all inbound connections, but if a context path is set, it can assist the application with building URIs (in HTML for example). This value will be accessible via theHTTPRequest.getContextPath()method.- Parameters:
contextPath- The context path for the server.- Returns:
- This.
-
withExpectValidator
Sets an ExpectValidator that is used if a client sends the server aExpect: 100-continueheader.- Parameters:
validator- The validator.- Returns:
- This.
-
withHandler
Sets the handler that will process the requests.- Parameters:
handler- The handler that processes the requests.- Returns:
- This.
-
withInitialReadTimeout
Sets the duration that the server will attempt to read the first byte from a client. This is the very first byte after the socket connection has been accepted by the server. Defaults to 2 seconds.- Parameters:
duration- The duration.- Returns:
- This.
-
withInstrumenter
Sets an instrumenter that the server will notify when events and conditions happen.- Parameters:
instrumenter- The instrumenter.- Returns:
- This.
-
withKeepAliveTimeoutDuration
Sets the duration that the server will allow client connections to remain open and idle after each request has been processed. This is the Keep-Alive state before the first byte of the next request is read. Defaults to 20 seconds.- Parameters:
duration- The duration.- Returns:
- This.
-
withListener
Adds a listener configuration for the server. This will listen on the address and port of the configuration but will share the thread pool of the server.- Parameters:
listener- The listener.- Returns:
- This.
-
withLoggerFactory
Sets the logger factory that all the HTTP server classes use to retrieve specific loggers. Defaults to theSystemOutLoggerFactory.- Parameters:
loggerFactory- The factory.- Returns:
- This.
-
withMaxResponseChunkSize
This configures the maximum size of a chunk in the response when the server is using chunked response encoding. Defaults to 16k.- Parameters:
size- The size in bytes.- Returns:
- This.
-
withMinimumReadThroughput
This configures the minimum number of bytes per second that a client must send a request to the server before the server closes the connection. Set this to -1 to disable this check.- Parameters:
bytesPerSecond- The bytes per second throughput.- Returns:
- This.
-
withMinimumWriteThroughput
This configures the minimum number of bytes per second that a client must read the response from the server before the server closes the connection. Set this to -1 to disable this check.- Parameters:
bytesPerSecond- The bytes per second throughput.- Returns:
- This.
-
withMultipartBufferSize
Sets the size of the buffer that is used to process the multipart request body. This defaults to 16k.- Parameters:
multipartBufferSize- The size of the buffer.- Returns:
- This.
-
withProcessingTimeoutDuration
Sets the duration that the server will allow worker threads to run after the final request byte is read and before the first response byte is written. Defaults to 10 seconds.- Parameters:
duration- The duration.- Returns:
- This.
-
withReadThroughputCalculationDelayDuration
This configures the duration of the initial delay before calculating and enforcing the minimum read throughput. Defaults to 5 seconds.This accounts for some warm up period, and exempts short-lived connections that may have smaller payloads that are more difficult to calculate a reasonable minimum read throughput.
- Parameters:
duration- The duration to delay the enforcement of the minimum read throughput.- Returns:
- This.
-
withRequestBufferSize
Sets the size of the buffer that is used to process the HTTP request. This defaults to 16k.- Parameters:
requestBufferSize- The size of the buffer.- Returns:
- This.
-
withResponseBufferSize
Sets the size of the buffer that is used to store the HTTP response before any bytes are written back to the client. This is useful when the server is generating the response but encounters an error. In this case, the server will throw out the response and change to a 500 error response. This defaults to 64k. Negative values disable the response buffer.- Parameters:
responseBufferSize- The size of the buffer. Set to -1 to disable buffering completely.- Returns:
- This.
-
withShutdownDuration
Sets the duration the server will wait for running requests to be completed. Defaults to 10 seconds.- Parameters:
duration- The duration the server will wait for all running request processing threads to complete their work.- Returns:
- This.
-
withWriteThroughputCalculationDelayDuration
This configures the duration of the initial delay before calculating and enforcing the minimum write throughput. Defaults to 5 seconds.This accounts for some warm up period, and exempts short-lived connections that may have smaller payloads that are more difficult to calculate a reasonable minimum write throughput.
- Parameters:
duration- The duration to delay the enforcement of the minimum write throughput.- Returns:
- This.
-