Skip to content

Commit

Permalink
Fix backpressure (vapor#2759)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne authored Jan 12, 2022
1 parent 28d9892 commit 8890136
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/Vapor/HTTP/Server/HTTPServerRequestDecoder.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NIO
import NIOHTTP1

final class HTTPServerRequestDecoder: ChannelInboundHandler, RemovableChannelHandler {
final class HTTPServerRequestDecoder: ChannelDuplexHandler, RemovableChannelHandler {
typealias InboundIn = HTTPServerRequestPart
typealias InboundOut = Request
typealias OutboundIn = Never
Expand Down Expand Up @@ -60,7 +60,7 @@ final class HTTPServerRequestDecoder: ChannelInboundHandler, RemovableChannelHan
case .ready, .awaitingEnd:
assertionFailure("Unexpected state: \(self.requestState)")
case .awaitingBody(let request):
if request.headers.first(name: .contentLength) == buffer.readableBytes.description {
if request.headers.first(name: .contentLength).flatMap(Int.init) ?? .max <= buffer.readableBytes {
self.requestState = .awaitingEnd(request, buffer)
} else {
let stream = Request.BodyStream(on: context.eventLoop)
Expand Down

0 comments on commit 8890136

Please sign in to comment.