Skip to content

Commit

Permalink
Minor changes to HTTP channel lhandler (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Apr 18, 2024
1 parent 1139189 commit 4283ebe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Sources/HummingbirdCore/Server/HTTP/HTTP1Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public struct HTTP1Channel: ServerChildChannel, HTTPChannelHandler {
[HTTPUserEventHandler(logger: logger)]
return channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.configureHTTPServerPipeline(
withPipeliningAssistance: false,
withErrorHandling: true
withPipeliningAssistance: false, // HTTP is pipelined by NIOAsyncChannel
withErrorHandling: true,
withOutboundHeaderValidation: false // Swift HTTP Types are already doing this validation
)
try channel.pipeline.syncOperations.addHandlers(childChannelHandlers)
return try NIOAsyncChannel(
Expand Down
5 changes: 1 addition & 4 deletions Sources/HummingbirdCore/Server/HTTP/HTTPChannelHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public protocol HTTPChannelHandler: ServerChildChannel {
@usableFromInline
enum HTTPChannelError: Error {
case unexpectedHTTPPart(HTTPRequestPart)
case closeConnection
}

enum HTTPState: Int, Sendable {
Expand Down Expand Up @@ -75,7 +74,7 @@ extension HTTPChannelHandler {
throw error
}
if request.headers[.connection] == "close" {
throw HTTPChannelError.closeConnection
return
}
// set to idle unless it is cancelled then exit
guard processingRequest.exchange(.idle) == .processing else { break }
Expand Down Expand Up @@ -112,8 +111,6 @@ extension HTTPChannelHandler {
} onCancel: {
asyncChannel.channel.close(mode: .input, promise: nil)
}
} catch HTTPChannelError.closeConnection {
// channel is being closed because we received a connection: close header
} catch {
// we got here because we failed to either read or write to the channel
logger.trace("Failed to read/write to Channel. Error: \(error)")
Expand Down

0 comments on commit 4283ebe

Please sign in to comment.