@@ -641,8 +641,8 @@ public class HTTPClient {
641
641
public var redirectConfiguration : RedirectConfiguration
642
642
/// Default client timeout, defaults to no timeouts.
643
643
public var timeout : Timeout
644
- /// Timeout of pooled connections
645
- public var maximumAllowedIdleTimeInConnectionPool : Optional < TimeAmount >
644
+ /// Connection pool configuration.
645
+ public var poolConfiguration : PoolConfiguration
646
646
/// Upstream proxy, defaults to no proxy.
647
647
public var proxy : Proxy ?
648
648
/// Enables automatic body decompression. Supported algorithms are gzip and deflate.
@@ -653,14 +653,14 @@ public class HTTPClient {
653
653
public init ( tlsConfiguration: TLSConfiguration ? = nil ,
654
654
redirectConfiguration: RedirectConfiguration ? = nil ,
655
655
timeout: Timeout = Timeout ( ) ,
656
- maximumAllowedIdleTimeInConnectionPool : TimeAmount ,
656
+ poolConfiguration : PoolConfiguration = PoolConfiguration ( ) ,
657
657
proxy: Proxy ? = nil ,
658
658
ignoreUncleanSSLShutdown: Bool = false ,
659
659
decompression: Decompression = . disabled) {
660
660
self . tlsConfiguration = tlsConfiguration
661
661
self . redirectConfiguration = redirectConfiguration ?? RedirectConfiguration ( )
662
662
self . timeout = timeout
663
- self . maximumAllowedIdleTimeInConnectionPool = maximumAllowedIdleTimeInConnectionPool
663
+ self . poolConfiguration = poolConfiguration
664
664
self . proxy = proxy
665
665
self . ignoreUncleanSSLShutdown = ignoreUncleanSSLShutdown
666
666
self . decompression = decompression
@@ -676,7 +676,7 @@ public class HTTPClient {
676
676
tlsConfiguration: tlsConfiguration,
677
677
redirectConfiguration: redirectConfiguration,
678
678
timeout: timeout,
679
- maximumAllowedIdleTimeInConnectionPool : . seconds ( 60 ) ,
679
+ poolConfiguration : PoolConfiguration ( ) ,
680
680
proxy: proxy,
681
681
ignoreUncleanSSLShutdown: ignoreUncleanSSLShutdown,
682
682
decompression: decompression
@@ -693,7 +693,7 @@ public class HTTPClient {
693
693
self . init ( tlsConfiguration: TLSConfiguration . forClient ( certificateVerification: certificateVerification) ,
694
694
redirectConfiguration: redirectConfiguration,
695
695
timeout: timeout,
696
- maximumAllowedIdleTimeInConnectionPool : maximumAllowedIdleTimeInConnectionPool ,
696
+ poolConfiguration : PoolConfiguration ( ) ,
697
697
proxy: proxy,
698
698
ignoreUncleanSSLShutdown: ignoreUncleanSSLShutdown,
699
699
decompression: decompression)
@@ -702,15 +702,15 @@ public class HTTPClient {
702
702
public init ( certificateVerification: CertificateVerification ,
703
703
redirectConfiguration: RedirectConfiguration ? = nil ,
704
704
timeout: Timeout = Timeout ( ) ,
705
- maximumAllowedIdleTimeInConnectionPool : TimeAmount = . seconds( 60 ) ,
705
+ poolConfiguration : TimeAmount = . seconds( 60 ) ,
706
706
proxy: Proxy ? = nil ,
707
707
ignoreUncleanSSLShutdown: Bool = false ,
708
708
decompression: Decompression = . disabled,
709
709
backgroundActivityLogger: Logger ? ) {
710
710
self . init ( tlsConfiguration: TLSConfiguration . forClient ( certificateVerification: certificateVerification) ,
711
711
redirectConfiguration: redirectConfiguration,
712
712
timeout: timeout,
713
- maximumAllowedIdleTimeInConnectionPool : maximumAllowedIdleTimeInConnectionPool ,
713
+ poolConfiguration : PoolConfiguration ( ) ,
714
714
proxy: proxy,
715
715
ignoreUncleanSSLShutdown: ignoreUncleanSSLShutdown,
716
716
decompression: decompression)
@@ -811,7 +811,7 @@ public class HTTPClient {
811
811
}
812
812
813
813
extension HTTPClient . Configuration {
814
- /// Timeout configuration
814
+ /// Timeout configuration.
815
815
public struct Timeout {
816
816
/// Specifies connect timeout.
817
817
public var connect : TimeAmount ?
@@ -860,6 +860,16 @@ extension HTTPClient.Configuration {
860
860
/// - warning: Cycle detection will keep all visited URLs in memory which means a malicious server could use this as a denial-of-service vector.
861
861
public static func follow( max: Int , allowCycles: Bool ) -> RedirectConfiguration { return . init( configuration: . follow( max: max, allowCycles: allowCycles) ) }
862
862
}
863
+
864
+ /// Connection pool configuration.
865
+ public struct PoolConfiguration : Hashable {
866
+ // Specifies amount of time connections are kept idle in the pool.
867
+ public var idleTimeout : TimeAmount
868
+
869
+ public init ( idleTimeout: TimeAmount = . seconds( 60 ) ) {
870
+ self . idleTimeout = idleTimeout
871
+ }
872
+ }
863
873
}
864
874
865
875
extension ChannelPipeline {
0 commit comments