File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,8 @@ internal class TaskHandler<T: HTTPClientResponseDelegate>: ChannelInboundHandler
286
286
headers. add ( name: " Host " , value: request. host)
287
287
}
288
288
289
+ headers. add ( name: " Connection " , value: " close " )
290
+
289
291
do {
290
292
try headers. validate ( body: request. body)
291
293
} catch {
@@ -321,6 +323,11 @@ internal class TaskHandler<T: HTTPClientResponseDelegate>: ChannelInboundHandler
321
323
322
324
self . state = . sent
323
325
self . delegate. didTransmitRequestBody ( task: self . task)
326
+
327
+ let channel = context. channel
328
+ self . promise. futureResult. whenComplete { _ in
329
+ channel. close ( promise: nil )
330
+ }
324
331
}
325
332
326
333
func channelRead( context: ChannelHandlerContext , data: NIOAny ) {
@@ -346,6 +353,7 @@ internal class TaskHandler<T: HTTPClientResponseDelegate>: ChannelInboundHandler
346
353
case . redirected( let head, let redirectURL) :
347
354
self . state = . end
348
355
self . redirectHandler? . redirect ( status: head. status, to: redirectURL, promise: self . promise)
356
+ context. close ( promise: nil )
349
357
default :
350
358
self . state = . end
351
359
do {
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class SwiftHTTPTests: XCTestCase {
55
55
head. headers. add ( name: " X-Test-Header " , value: " X-Test-Value " )
56
56
head. headers. add ( name: " Host " , value: " localhost " )
57
57
head. headers. add ( name: " Content-Length " , value: " 4 " )
58
+ head. headers. add ( name: " Connection " , value: " close " )
58
59
XCTAssertEqual ( HTTPClientRequestPart . head ( head) , recorder. writes [ 0 ] )
59
60
var buffer = ByteBufferAllocator ( ) . buffer ( capacity: 4 )
60
61
buffer. writeString ( " 1234 " )
You can’t perform that action at this time.
0 commit comments