Interface Configurable<T extends Configurable<T>>
- Type Parameters:
T- The type of configurable for casting.
- All Known Implementing Classes:
HTTPServer,HTTPServerConfiguration
-
Method Summary
Modifier and TypeMethodDescriptiondefault TwithBaseDir(Path baseDir) Sets the base directory for this server.default TwithClientTimeout(Duration duration) Sets the duration that the server will allow client connections to remain open.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 TwithInstrumenter(Instrumenter instrumenter) Sets an instrumenter that the server will notify when events and conditions happen.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 TwithMaxOutputBufferQueueLength(int outputBufferQueueLength) Sets the maximum length of the output buffer queue.default TwithMaxPreambleLength(int maxLength) Sets the max preamble length (the start-line and headers constitute the head).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 TwithNumberOfWorkerThreads(int numberOfWorkerThreads) Sets the number of worker threads that will handle requests coming into the HTTP server.default TwithPreambleBufferSize(int size) Sets the size of the preamble buffer (that is the buffer that reads the start-line and headers).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 process the HTTP response.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.
-
withClientTimeout
Sets the duration that the server will allow client connections to remain open. This includes Keep-Alive as well as read timeout. Defaults to 20 seconds.- Parameters:
duration- The duration.- 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.
-
withInstrumenter
Sets an instrumenter that the server will notify when events and conditions happen.- Parameters:
instrumenter- The instrumenter.- 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.
-
withMaxOutputBufferQueueLength
Sets the maximum length of the output buffer queue. Defaults to 128.This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by values returned from
HTTPServerConfiguration.getResponseBufferSize()andHTTPServerConfiguration.getNumberOfWorkerThreads().- Parameters:
outputBufferQueueLength- The length of the output buffer queue.- Returns:
- This.
-
withMaxPreambleLength
Sets the max preamble length (the start-line and headers constitute the head). Defaults to 64k- Parameters:
maxLength- The max preamble length.- 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.- 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.- 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.
-
withNumberOfWorkerThreads
Sets the number of worker threads that will handle requests coming into the HTTP server. Defaults to 40.This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by the returned from
HTTPServerConfiguration.getResponseBufferSize()andHTTPServerConfiguration.getMaxOutputBufferQueueLength().- Parameters:
numberOfWorkerThreads- The number of worker threads.- Returns:
- This.
-
withPreambleBufferSize
Sets the size of the preamble buffer (that is the buffer that reads the start-line and headers). Defaults to 4096.- Parameters:
size- The buffer size.- 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 process the HTTP response. This defaults to 16k.This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by the returned from
HTTPServerConfiguration.getNumberOfWorkerThreads()andHTTPServerConfiguration.getMaxOutputBufferQueueLength().- Parameters:
responseBufferSize- The size of the buffer.- 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.
-