From 0b5ef3693f62b4c72da7b77f7ede816a697408d1 Mon Sep 17 00:00:00 2001 From: Mathias Date: Wed, 16 Oct 2013 17:40:02 +0200 Subject: [PATCH] ! can: add `max-encryption-chunk-size` setting to ClientConnectionSettings and ServerSettings --- spray-can/src/main/resources/reference.conf | 12 ++++++++++++ .../spray/can/client/ClientConnectionSettings.scala | 9 +++++---- .../main/scala/spray/can/server/ServerSettings.scala | 9 +++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/spray-can/src/main/resources/reference.conf b/spray-can/src/main/resources/reference.conf index 32a5e4c023..accb525ec0 100644 --- a/spray-can/src/main/resources/reference.conf +++ b/spray-can/src/main/resources/reference.conf @@ -120,6 +120,12 @@ spray.can { # doesn't have to be fiddled with in most applications. response-header-size-hint = 512 + # For HTTPS connections this setting specified the maximum number of + # bytes that are encrypted in one go. Large responses are broken down in + # chunks of this size so as to already begin sending before the response has + # been encrypted entirely. + max-encryption-chunk-size = 1m + # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 1s @@ -210,6 +216,12 @@ spray.can { # doesn't have to be fiddled with in most applications. request-header-size-hint = 512 + # For HTTPS connections this setting specified the maximum number of + # bytes that are encrypted in one go. Large requests are broken down in + # chunks of this size so as to already begin sending before the request has + # been encrypted entirely. + max-encryption-chunk-size = 1m + # The time period within which the TCP connecting process must be completed. # Set to `infinite` to disable. connecting-timeout = 10s diff --git a/spray-can/src/main/scala/spray/can/client/ClientConnectionSettings.scala b/spray-can/src/main/scala/spray/can/client/ClientConnectionSettings.scala index a25f41dfab..625dd1fb34 100644 --- a/spray-can/src/main/scala/spray/can/client/ClientConnectionSettings.scala +++ b/spray-can/src/main/scala/spray/can/client/ClientConnectionSettings.scala @@ -30,6 +30,7 @@ case class ClientConnectionSettings( responseChunkAggregationLimit: Int, chunklessStreaming: Boolean, requestHeaderSizeHint: Int, + maxEncryptionChunkSize: Int, connectingTimeout: Duration, parserSettings: ParserSettings, proxySettings: Map[String, ProxySettings]) { @@ -37,10 +38,9 @@ case class ClientConnectionSettings( requirePositive(idleTimeout) requirePositive(requestTimeout) requirePositive(reapingCycle) - require(0 <= responseChunkAggregationLimit && responseChunkAggregationLimit <= Int.MaxValue, - "response-chunk-aggregation-limit must be >= 0 and <= Int.MaxValue") - require(0 <= requestHeaderSizeHint && requestHeaderSizeHint <= Int.MaxValue, - "request-size-hint must be >= 0 and <= Int.MaxValue") + require(0 <= responseChunkAggregationLimit, "response-chunk-aggregation-limit must be >= 0") + require(0 < requestHeaderSizeHint, "request-size-hint must be > 0") + require(0 < maxEncryptionChunkSize, "max-encryption-chunk-size must be > 0") requirePositive(connectingTimeout) } @@ -59,6 +59,7 @@ object ClientConnectionSettings extends SettingsCompanion[ClientConnectionSettin c getBytes "response-chunk-aggregation-limit" toInt, c getBoolean "chunkless-streaming", c getBytes "request-header-size-hint" toInt, + c getBytes "max-encryption-chunk-size" toInt, c getDuration "connecting-timeout", ParserSettings fromSubConfig c.getConfig("parsing"), ProxySettings fromSubConfig c.getConfig("proxy")) diff --git a/spray-can/src/main/scala/spray/can/server/ServerSettings.scala b/spray-can/src/main/scala/spray/can/server/ServerSettings.scala index 4bc1f2d4ce..e27eb9a11c 100644 --- a/spray-can/src/main/scala/spray/can/server/ServerSettings.scala +++ b/spray-can/src/main/scala/spray/can/server/ServerSettings.scala @@ -41,16 +41,16 @@ case class ServerSettings( verboseErrorMessages: Boolean, requestChunkAggregationLimit: Int, responseHeaderSizeHint: Int, + maxEncryptionChunkSize: Int, defaultHostHeader: Host, backpressureSettings: Option[BackpressureSettings], parserSettings: ParserSettings) { requirePositive(reapingCycle) require(0 <= pipeliningLimit && pipeliningLimit <= 128, "pipelining-limit must be >= 0 and <= 128") - require(0 <= requestChunkAggregationLimit && requestChunkAggregationLimit <= Int.MaxValue, - "request-chunk-aggregation-limit must be >= 0 and <= Int.MaxValue") - require(0 <= responseHeaderSizeHint && responseHeaderSizeHint <= Int.MaxValue, - "response-size-hint must be >= 0 and <= Int.MaxValue") + require(0 <= requestChunkAggregationLimit, "request-chunk-aggregation-limit must be >= 0") + require(0 <= responseHeaderSizeHint, "response-size-hint must be > 0") + require(0 < maxEncryptionChunkSize, "max-encryption-chunk-size must be > 0") } object ServerSettings extends SettingsCompanion[ServerSettings]("spray.can.server") { @@ -96,6 +96,7 @@ object ServerSettings extends SettingsCompanion[ServerSettings]("spray.can.serve c getBoolean "verbose-error-messages", c getBytes "request-chunk-aggregation-limit" toInt, c getBytes "response-header-size-hint" toInt, + c getBytes "max-encryption-chunk-size" toInt, defaultHostHeader = HttpParser.parseHeader(RawHeader("Host", c getString "default-host-header")) match { case Right(x: Host) ⇒ x