Class HTTPServerConfiguration

java.lang.Object
io.fusionauth.http.server.HTTPServerConfiguration
All Implemented Interfaces:
Configurable<HTTPServerConfiguration>

public class HTTPServerConfiguration extends Object implements Configurable<HTTPServerConfiguration>
The HTTP Server configuration.
Author:
Brian Pontarelli
  • Constructor Details

    • HTTPServerConfiguration

      public HTTPServerConfiguration()
  • Method Details

    • configuration

      public HTTPServerConfiguration configuration()
      Specified by:
      configuration in interface Configurable<HTTPServerConfiguration>
      Returns:
      This.
    • getBaseDir

      public Path getBaseDir()
    • getClientTimeoutDuration

      public Duration getClientTimeoutDuration()
    • getContextPath

      public String getContextPath()
    • getExpectValidator

      public ExpectValidator getExpectValidator()
    • getHandler

      public HTTPHandler getHandler()
    • getInstrumenter

      public Instrumenter getInstrumenter()
    • getListeners

      public List<HTTPListenerConfiguration> getListeners()
    • getLoggerFactory

      public LoggerFactory getLoggerFactory()
    • getMaxHeadLength

      public int getMaxHeadLength()
    • getMaxOutputBufferQueueLength

      public int getMaxOutputBufferQueueLength()
      This configuration will affect the runtime memory requirement.

      The maximum memory requirement for the output buffer can be calculated multiplying this value by the values returned from getResponseBufferSize() and * getNumberOfWorkerThreads().

      Returns:
      the maximum output buffer queue length.
    • getMinimumReadThroughput

      public long getMinimumReadThroughput()
      This configuration is the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.
      Returns:
      The minimum throughput for any connection with the server in bytes per second.
    • getMinimumWriteThroughput

      public long getMinimumWriteThroughput()
      This configuration is the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.
      Returns:
      The minimum throughput for any connection with the server in bytes per second.
    • getMultipartBufferSize

      public int getMultipartBufferSize()
    • getNumberOfWorkerThreads

      public int getNumberOfWorkerThreads()
      The number of worker threads. This configuration will affect the runtime memory requirement.

      The maximum memory requirement for the output buffer can be calculated multiplying this value by the values returned from getMaxOutputBufferQueueLength() and * getResponseBufferSize().

      Returns:
      the number of worker threads.
    • getPreambleBufferSize

      public int getPreambleBufferSize()
    • getReadThroughputCalculationDelay

      public Duration getReadThroughputCalculationDelay()
      Returns:
      the duration that will be used to delay the calculation and enforcement of the minimum read throughput.
    • getRequestBufferSize

      public int getRequestBufferSize()
    • getResponseBufferSize

      public int getResponseBufferSize()
      The size of the response buffer in bytes. This configuration will affect the runtime memory requirement.

      The maximum memory requirement for the output buffer can be calculated multiplying this value by the values returned from getMaxOutputBufferQueueLength() and * getNumberOfWorkerThreads().

      Returns:
      the response buffer size in bytes.
    • getShutdownDuration

      public Duration getShutdownDuration()
    • getWriteThroughputCalculationDelay

      public Duration getWriteThroughputCalculationDelay()
      Returns:
      the duration that will be used to delay the calculation and enforcement of the minimum write throughput.
    • isCompressByDefault

      public boolean isCompressByDefault()
    • withBaseDir

      public HTTPServerConfiguration withBaseDir(Path baseDir)
      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.
      Specified by:
      withBaseDir in interface Configurable<HTTPServerConfiguration>
      Parameters:
      baseDir - The base dir.
      Returns:
      This.
    • withClientTimeout

      public HTTPServerConfiguration withClientTimeout(Duration duration)
      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.
      Specified by:
      withClientTimeout in interface Configurable<HTTPServerConfiguration>
      Parameters:
      duration - The duration.
      Returns:
      This.
    • withCompressByDefault

      public HTTPServerConfiguration withCompressByDefault(boolean compressByDefault)
      Sets the default compression behavior for the HTTP response. This behavior can be optionally set per response. See HTTPResponse.setCompress(boolean). Defaults to true.
      Specified by:
      withCompressByDefault in interface Configurable<HTTPServerConfiguration>
      Parameters:
      compressByDefault - true if you want to compress by default, or false to not compress by default.
      Returns:
      This.
    • withContextPath

      public HTTPServerConfiguration withContextPath(String contextPath)
      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 the HTTPRequest.getContextPath() method.
      Specified by:
      withContextPath in interface Configurable<HTTPServerConfiguration>
      Parameters:
      contextPath - The context path for the server.
      Returns:
      This.
    • withExpectValidator

      public HTTPServerConfiguration withExpectValidator(ExpectValidator validator)
      Sets an ExpectValidator that is used if a client sends the server a Expect: 100-continue header.
      Specified by:
      withExpectValidator in interface Configurable<HTTPServerConfiguration>
      Parameters:
      validator - The validator.
      Returns:
      This.
    • withHandler

      public HTTPServerConfiguration withHandler(HTTPHandler handler)
      Sets the handler that will process the requests.
      Specified by:
      withHandler in interface Configurable<HTTPServerConfiguration>
      Parameters:
      handler - The handler that processes the requests.
      Returns:
      This.
    • withInstrumenter

      public HTTPServerConfiguration withInstrumenter(Instrumenter instrumenter)
      Sets an instrumenter that the server will notify when events and conditions happen.
      Specified by:
      withInstrumenter in interface Configurable<HTTPServerConfiguration>
      Parameters:
      instrumenter - The instrumenter.
      Returns:
      This.
    • withListener

      public HTTPServerConfiguration withListener(HTTPListenerConfiguration listener)
      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.
      Specified by:
      withListener in interface Configurable<HTTPServerConfiguration>
      Parameters:
      listener - The listener.
      Returns:
      This.
    • withLoggerFactory

      public HTTPServerConfiguration withLoggerFactory(LoggerFactory loggerFactory)
      Sets the logger factory that all the HTTP server classes use to retrieve specific loggers. Defaults to the SystemOutLoggerFactory.
      Specified by:
      withLoggerFactory in interface Configurable<HTTPServerConfiguration>
      Parameters:
      loggerFactory - The factory.
      Returns:
      This.
    • withMaxOutputBufferQueueLength

      public HTTPServerConfiguration withMaxOutputBufferQueueLength(int outputBufferQueueLength)
      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 getResponseBufferSize() and getNumberOfWorkerThreads().

      Specified by:
      withMaxOutputBufferQueueLength in interface Configurable<HTTPServerConfiguration>
      Parameters:
      outputBufferQueueLength - The length of the output buffer queue.
      Returns:
      This.
    • withMaxPreambleLength

      public HTTPServerConfiguration withMaxPreambleLength(int maxLength)
      Sets the max preamble length (the start-line and headers constitute the head). Defaults to 64k
      Specified by:
      withMaxPreambleLength in interface Configurable<HTTPServerConfiguration>
      Parameters:
      maxLength - The max preamble length.
      Returns:
      This.
    • withMinimumReadThroughput

      public HTTPServerConfiguration withMinimumReadThroughput(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.
      Specified by:
      withMinimumReadThroughput in interface Configurable<HTTPServerConfiguration>
      Parameters:
      bytesPerSecond - The bytes per second throughput.
      Returns:
      This.
    • withMinimumWriteThroughput

      public HTTPServerConfiguration withMinimumWriteThroughput(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.
      Specified by:
      withMinimumWriteThroughput in interface Configurable<HTTPServerConfiguration>
      Parameters:
      bytesPerSecond - The bytes per second throughput.
      Returns:
      This.
    • withMultipartBufferSize

      public HTTPServerConfiguration withMultipartBufferSize(int multipartBufferSize)
      Sets the size of the buffer that is used to process the multipart request body. This defaults to 16k.
      Specified by:
      withMultipartBufferSize in interface Configurable<HTTPServerConfiguration>
      Parameters:
      multipartBufferSize - The size of the buffer.
      Returns:
      This.
    • withNumberOfWorkerThreads

      public HTTPServerConfiguration withNumberOfWorkerThreads(int numberOfWorkerThreads)
      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 getResponseBufferSize() and getMaxOutputBufferQueueLength().

      Specified by:
      withNumberOfWorkerThreads in interface Configurable<HTTPServerConfiguration>
      Parameters:
      numberOfWorkerThreads - The number of worker threads.
      Returns:
      This.
    • withPreambleBufferSize

      public HTTPServerConfiguration withPreambleBufferSize(int size)
      Sets the size of the preamble buffer (that is the buffer that reads the start-line and headers). Defaults to 4096.
      Specified by:
      withPreambleBufferSize in interface Configurable<HTTPServerConfiguration>
      Parameters:
      size - The buffer size.
      Returns:
      This.
    • withReadThroughputCalculationDelayDuration

      public HTTPServerConfiguration withReadThroughputCalculationDelayDuration(Duration duration)
      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.

      Specified by:
      withReadThroughputCalculationDelayDuration in interface Configurable<HTTPServerConfiguration>
      Parameters:
      duration - The duration to delay the enforcement of the minimum read throughput.
      Returns:
      This.
    • withRequestBufferSize

      public HTTPServerConfiguration withRequestBufferSize(int requestBufferSize)
      Sets the size of the buffer that is used to process the HTTP request. This defaults to 16k.
      Specified by:
      withRequestBufferSize in interface Configurable<HTTPServerConfiguration>
      Parameters:
      requestBufferSize - The size of the buffer.
      Returns:
      This.
    • withResponseBufferSize

      public HTTPServerConfiguration withResponseBufferSize(int responseBufferSize)
      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 getNumberOfWorkerThreads() and getMaxOutputBufferQueueLength().

      Specified by:
      withResponseBufferSize in interface Configurable<HTTPServerConfiguration>
      Parameters:
      responseBufferSize - The size of the buffer.
      Returns:
      This.
    • withShutdownDuration

      public HTTPServerConfiguration withShutdownDuration(Duration duration)
      Sets the duration the server will wait for running requests to be completed. Defaults to 10 seconds.
      Specified by:
      withShutdownDuration in interface Configurable<HTTPServerConfiguration>
      Parameters:
      duration - The duration the server will wait for all running request processing threads to complete their work.
      Returns:
      This.
    • withWriteThroughputCalculationDelayDuration

      public HTTPServerConfiguration withWriteThroughputCalculationDelayDuration(Duration duration)
      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.

      Specified by:
      withWriteThroughputCalculationDelayDuration in interface Configurable<HTTPServerConfiguration>
      Parameters:
      duration - The duration to delay the enforcement of the minimum write throughput.
      Returns:
      This.