Skip to content

Commit

Permalink
Fixed an issue where HTTP2 didn't support response compression and re…
Browse files Browse the repository at this point in the history
…quest recompression

Fixes #3125
  • Loading branch information
dimitribouniol committed Jan 7, 2024
1 parent 0680f9f commit 982e424
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Sources/Vapor/HTTP/Server/HTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,28 @@ extension ChannelPipeline {
let http2 = HTTP2FramePayloadToHTTP1ServerCodec()
handlers.append(http2)

// add response compressor if configured
switch configuration.responseCompression.storage {
case .enabled(let initialByteBufferCapacity):
let responseCompressionHandler = HTTPResponseCompressor(
initialByteBufferCapacity: initialByteBufferCapacity
)
handlers.append(responseCompressionHandler)
case .disabled:
break
}

// add request decompressor if configured
switch configuration.requestDecompression.storage {
case .enabled(let limit):
let requestDecompressionHandler = NIOHTTPRequestDecompressor(
limit: limit
)
handlers.append(requestDecompressionHandler)
case .disabled:
break
}

// add NIO -> HTTP request decoder
let serverReqDecoder = HTTPServerRequestDecoder(
application: application
Expand Down

0 comments on commit 982e424

Please sign in to comment.