Add an HTTP/1.1 connection pool (#105)

motivation: Better performance thanks to connection reuse

changes:
- Added a connection pool for HTTP/1.1
- All requests automatically use the connection pool
- Up to 8 parallel connections per (scheme, host, port)
- Multiple additional unit tests
This commit is contained in:
Trevör
2020-02-25 15:43:16 +00:00
committed by GitHub
parent de7421906c
commit 19e2ea727e
10 changed files with 1726 additions and 208 deletions
@@ -69,6 +69,7 @@ internal final class HTTPClientProxyHandler: ChannelDuplexHandler, RemovableChan
case awaitingResponse
case connecting
case connected
case failed
}
private let host: String
@@ -102,6 +103,7 @@ internal final class HTTPClientProxyHandler: ChannelDuplexHandler, RemovableChan
// blank line that concludes the successful response's header section
break
case 407:
self.readState = .failed
context.fireErrorCaught(HTTPClientError.proxyAuthenticationRequired)
default:
// Any response other than a successful response
@@ -119,6 +121,8 @@ internal final class HTTPClientProxyHandler: ChannelDuplexHandler, RemovableChan
self.readBuffer.append(data)
case .connected:
context.fireChannelRead(data)
case .failed:
break
}
}