RequestBag keeps the request body after an early response with status >= 300
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- swift
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with HTTPRequestStateMachine and the request body stream handling when a response head has status 300 or higher; trace how the channel handler releases the request when the response ends. Read RequestBagTests.swift and HTTP1ClientChannelHandlerTests.swift, then run the focused testUploadIsCancelledIf and testUploadResumesIfResponseBelow300 tests. Done means the task and pending write futures complete after the response, and a later body write fails with requestStreamCancelled. The async/await Transaction case is tracked in #939.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
AsyncHTTPClient commit hash: 017115279d09dbfd262a6c678e96d31c90b3b2aa (main)
Context
The caller uses HTTPClient.execute(request:delegate:) or an EventLoopFuture method that calls it, for example post(url:body:). The request has an HTTPClient.Body.stream body. The server sends a complete >= 300 response, for example 401 or 413, before the request body ends.
At a >= 300 response head, HTTPRequestStateMachine pauses the request body stream and does not resume it. When the response ends, the channel handler releases the request. No later event completes the write future. The body writer waits forever.
The write future callbacks keep these items in memory:
- the
RequestBag - the delegate
- the data that the body writer holds
The async/await API (Transaction) has the same bug: #939.
Steps to reproduce
The tests use EmbeddedEventLoop and EmbeddedChannel and open no network connections.
These commands add only the new tests from https://github.com/beshkenadze/async-http-client/tree/fix/requestbag-stop-request-body-after-early-response. The library sources stay at 0171152.
git clone https://github.com/swift-server/async-http-client.git
cd async-http-client
git checkout 017115279d09dbfd262a6c678e96d31c90b3b2aa
git fetch https://github.com/beshkenadze/async-http-client.git fix/requestbag-stop-request-body-after-early-response
git checkout FETCH_HEAD -- Tests/AsyncHTTPClientTests/RequestBagTests.swift Tests/AsyncHTTPClientTests/HTTP1ClientChannelHandlerTests.swift
swift test --filter 'testUploadIsCancelledIf|testUploadResumesIfResponseBelow300'
Expected result
After the delegate consumes the complete response, the task succeeds with the response. Each write future completes. A later body write fails with HTTPClientError.requestStreamCancelled.
Actual result
4 of 5 tests fail. RequestBagTests.testUploadResumesIfResponseBelow300EndsWhileUploadIsPaused (status 200) passes.
Test (testUploadIsCancelledIf...) |
State when the 413 response ends | Result |
|---|---|---|
RequestBagTests ...ResponseAtLeast300EndsWhileUploadIsPaused |
The delegate consumed the response. A body write waits. | The task and the write future do not complete. |
HTTP1ClientChannelHandlerTests ...ResponseAtLeast300EndsWhileUploadIsPaused |
Same, through the HTTP/1 channel handler. | The write future does not complete. |
RequestBagTests ...ResponseAtLeast300EndsWhileWaitingForNextBodyPart |
The delegate consumed the response. No body write waits. | The task does not complete. The next body write goes to the executor, and its future does not complete. |
RequestBagTests ...BufferedResponseAtLeast300EndsWhileUploadIsPaused |
The delegate did not consume the response yet. The RequestBag buffers the response body. A body write waits. |
The task succeeds. The write future does not complete. |
Versions
- OS: macOS 27.0.1 (26A434)
$ swift --version
swift-driver version: 1.168.6 Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)
Target: arm64-apple-macosx27.0.0
$ uname -srvm
Darwin 27.0.0 Darwin Kernel Version 27.0.0: Tue Aug 11 21:22:49 PDT 2026; root:xnu-13432.1.9~1/RELEASE_ARM64_T6000 arm64
- Ngôn ngữ chính
- Swift
- Star
- 1.1k
- Fork
- 159
- Merge trung bình
- 2 giờ 56 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của swift-server/async-http-client
-
RFC: pluggable authenticator APIĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
swift-server/async-http-client#946 · 2 bình luận ·
-
HTTP/2 stream stays half-closed after an early response with status >= 300Có thể đã có người làm @beshkenadze đã nhận 19 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
Transaction keeps the request body after an early response with status >= 300Có thể đã có người làm @beshkenadze đã nhận 19 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
-
Invalid state: idleĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
swift-server/async-http-client#927 · 2 bình luận ·
Tất cả issue của swift-server/async-http-client
Issue tương tự
-
a: plugins d: docs/ fyi-macos P2 platform-ios platform-macos team-ios
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
swiftlang/github-workflows#352 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jphacks/kz_2601#1375 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày