mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-05-03 07:32:29 +00:00
Add test for HTTP2 request with large header (#659)
Motivation We currently don't handle large headers well which trigger a channel writability change event. Modification Add failing (but currently skipped) tests which reproduces the issue Result We can reliably reproduce the large request header issue in an integration and unit test. Note that the actual fix is not included to make reviewing easier and will come in a follow up PR.
This commit is contained in:
@@ -329,17 +329,32 @@ internal final class HTTPBin<RequestHandler: ChannelInboundHandler> where
|
||||
// supports http1.1 connections only, which can be either plain text or encrypted
|
||||
case http1_1(ssl: Bool = false, compress: Bool = false)
|
||||
// supports http1.1 and http2 connections which must be always encrypted
|
||||
case http2(compress: Bool)
|
||||
case http2(
|
||||
compress: Bool = false,
|
||||
settings: HTTP2Settings? = nil
|
||||
)
|
||||
|
||||
// supports request decompression and http response compression
|
||||
var compress: Bool {
|
||||
switch self {
|
||||
case .refuse:
|
||||
return false
|
||||
case .http1_1(ssl: _, compress: let compress), .http2(compress: let compress):
|
||||
case .http1_1(ssl: _, compress: let compress), .http2(compress: let compress, _):
|
||||
return compress
|
||||
}
|
||||
}
|
||||
|
||||
var httpSettings: HTTP2Settings {
|
||||
switch self {
|
||||
case .http1_1, .http2(_, nil), .refuse:
|
||||
return [
|
||||
HTTP2Setting(parameter: .maxConcurrentStreams, value: 10),
|
||||
HTTP2Setting(parameter: .maxHeaderListSize, value: HPACKDecoder.defaultMaxHeaderListSize),
|
||||
]
|
||||
case .http2(_, .some(let customSettings)):
|
||||
return customSettings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Proxy {
|
||||
@@ -565,11 +580,7 @@ internal final class HTTPBin<RequestHandler: ChannelInboundHandler> where
|
||||
// Successful upgrade to HTTP/2. Let the user configure the pipeline.
|
||||
let http2Handler = NIOHTTP2Handler(
|
||||
mode: .server,
|
||||
initialSettings: [
|
||||
// TODO: make max concurrent streams configurable
|
||||
HTTP2Setting(parameter: .maxConcurrentStreams, value: 10),
|
||||
HTTP2Setting(parameter: .maxHeaderListSize, value: HPACKDecoder.defaultMaxHeaderListSize),
|
||||
]
|
||||
initialSettings: self.mode.httpSettings
|
||||
)
|
||||
let multiplexer = HTTP2StreamMultiplexer(
|
||||
mode: .server,
|
||||
|
||||
Reference in New Issue
Block a user