in finagle-http/src/main/scala/com/twitter/finagle/Http.scala [444:623]
protected def copy1(
stack: Stack[ServiceFactory[Request, Response]] = this.stack,
params: Stack.Params = this.params
): Server = copy(stack, params)
/**
* For HTTP1*, configures the max size of headers
* For HTTP2, sets the MAX_HEADER_LIST_SIZE setting which is the maximum
* number of uncompressed bytes of header name/values.
* These may be set independently via the .configured API.
*/
def withMaxHeaderSize(size: StorageUnit): Server =
this
.configured(http.param.MaxHeaderSize(size))
.configured(http2.param.MaxHeaderListSize(size))
/**
* Configures the maximum request size this server can receive.
*/
def withMaxRequestSize(size: StorageUnit): Server =
configured(http.param.MaxRequestSize(size))
/**
* Streaming allows applications to work with HTTP messages that have large
* (or infinite) content bodies.
*
* If `enabled` is set to `true`, the message content is available through a
* [[com.twitter.io.Reader]], which gives the application a handle to the byte stream.
*
* If `enabled` is set to `false`, the entire message content is buffered up to
* maximum allowed message size.
*/
def withStreaming(enabled: Boolean): Server =
configured(http.param.Streaming(enabled))
/**
* Streaming allows applications to work with HTTP messages that have large
* (or infinite) content bodies.
*
* This method configures `fixedLengthStreamedAfter` limit, which effectively turns on
* streaming (think `withStreaming(true)`). The `fixedLengthStreamedAfter`, however, disables
* streaming for sufficiently small messages of known fixed length.
*
* If `Content-Length` of a message does not exceed `fixedLengthStreamedAfter` it is
* buffered and its content is available through [[Request.content]] or
* [[Request.contentString]].
*
* Messages without `Content-Length` header are always streamed regardless of their
* actual content length and the `fixedLengthStreamedAfter` value.
*
* [[Request.isChunked]] should be used to determine whether a message is streamed
* (`isChunked == true`) or buffered (`isChunked == false`).
*/
def withStreaming(fixedLengthStreamedAfter: StorageUnit): Server =
configured(http.param.Streaming(fixedLengthStreamedAfter))
/**
* Enables decompression of http content bodies.
*/
def withDecompression(enabled: Boolean): Server =
configured(http.param.Decompression(enabled))
/**
* The compression level to use. If passed the default value (-1) then it will use
* [[com.twitter.finagle.http.codec.TextualContentCompressor TextualContentCompressor]]
* which will compress text-like content-types with the default compression level (6).
* Otherwise, use the Netty `HttpContentCompressor` for all content-types with specified
* compression level.
*/
def withCompressionLevel(level: Int): Server =
configured(http.param.CompressionLevel(level))
/**
* Configures the maximum initial http line length the server is
* willing to accept.
*/
def withMaxInitialLineSize(size: StorageUnit): Server =
configured(http.param.MaxInitialLineSize(size))
/**
* Enable the collection of HTTP specific metrics. See [[http.filter.StatsFilter]].
*/
def withHttpStats: Server =
withStack(stack.replace(http.filter.StatsFilter.role, http.filter.StatsFilter.module))
/**
* Enable HTTP/2
*
* @note this will override whatever has been set in the toggle.
*/
def withHttp2: Server =
configuredParams(Http2Params)
/**
* Disable HTTP/2
*
* @note this will override whatever has been set in the toggle.
*/
def withNoHttp2: Server =
configuredParams(Http11Params)
/**
* Enable kerberos server authentication for http requests
*/
def withKerberos(serverKerberosConfiguration: ServerKerberosConfiguration): Server = configured(
http.param.ServerKerberos(serverKerberosConfiguration))
/**
* By default finagle-http automatically sends 100-CONTINUE responses to inbound
* requests which set the 'Expect: 100-Continue' header. Streaming servers will
* always return 100-CONTINUE. Non-streaming servers will compare the
* content-length header to the configured limit (see: `withMaxRequestSize`)
* and send either a 100-CONTINUE or 413-REQUEST ENTITY TOO LARGE as
* appropriate. This method disables those automatic responses.
*
* @note Servers operating as proxies should disable automatic responses in
* order to allow origin servers to determine whether the expectation
* can be met.
* @note Disabling automatic continues is only supported in
* [[com.twitter.finagle.Http.HttpImpl.Http11Impl]] servers.
*/
def withNoAutomaticContinue: Server =
configured(http.param.AutomaticContinue(false))
/**
* When enabled simultaneously with TLS (`withTransport.tls`), this server would use
* both cleartext and TLS socket connections on the same port (default: `disabled`).
*/
def withTlsSnooping: Server =
configured(SnoopingLevelInterpreter.EnabledForNonNegotiatingProtocols)
/**
* Disables TLS snooping for this server.
*/
def withNoTlsSnooping: Server =
configured(SnoopingLevelInterpreter.Off)
// Java-friendly forwarders
// See https://issues.scala-lang.org/browse/SI-8905
override val withAdmissionControl: finagle.param.ServerAdmissionControlParams[Server] =
new finagle.param.ServerAdmissionControlParams(this)
override val withTransport: finagle.param.ServerTransportParams[Server] =
new finagle.param.ServerTransportParams(this)
override val withSession: finagle.param.ServerSessionParams[Server] =
new finagle.param.ServerSessionParams(this)
override def withResponseClassifier(
responseClassifier: finagle.service.ResponseClassifier
): Server =
super.withResponseClassifier(responseClassifier)
override def withLabel(label: String): Server = super.withLabel(label)
override def withStatsReceiver(statsReceiver: StatsReceiver): Server =
super.withStatsReceiver(statsReceiver)
override def withMonitor(monitor: Monitor): Server = super.withMonitor(monitor)
override def withTracer(tracer: Tracer): Server = super.withTracer(tracer)
override def withExceptionStatsHandler(exceptionStatsHandler: ExceptionStatsHandler): Server =
super.withExceptionStatsHandler(exceptionStatsHandler)
override def withRequestTimeout(timeout: Duration): Server = super.withRequestTimeout(timeout)
override def withStack(stack: Stack[ServiceFactory[Request, Response]]): Server =
super.withStack(stack)
override def withStack(
fn: Stack[ServiceFactory[Request, Response]] => Stack[ServiceFactory[Request, Response]]
): Server =
super.withStack(fn)
override def withExecutionOffloaded(executor: ExecutorService): Server =
super.withExecutionOffloaded(executor)
override def withExecutionOffloaded(pool: FuturePool): Server =
super.withExecutionOffloaded(pool)
override def configured[P](psp: (P, Stack.Param[P])): Server = super.configured(psp)
override def configuredParams(newParams: Stack.Params): Server =
super.configuredParams(newParams)
protected def superServe(
addr: SocketAddress,
factory: ServiceFactory[Request, Response]
): ListeningServer = {
super.serve(addr, factory)
}