Upload requests with Transfer-Encoding: chunked hang forever

Đang mở
#49 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@maddie đang làm issue này rồi.

Từ ngày 17/8/2026.

  • #50 của @maddie — đang mở

Đá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
Ít trao đổi
Công nghệ
rust
Lĩnh vực
api, backend, networking

Hướng nghiên cứu

Bắt đầu tại src/http/request.rs, ở nhánh BodyType::Chunked, và xem lại cách BufReader của Tokio hiện có đọc request body. Tái hiện một lần tải lên chunked hữu hạn qua một kết nối keep-alive, sau đó xác minh rằng dữ liệu chunk, CRLF kết thúc và trailers được tiêu thụ, đồng thời request hoàn tất thay vì chờ EOF.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

The hand-written HTTP parser never chunk-decodes request bodies: BodyType::Chunked (src/http/request.rs) reads the raw stream in fixed 1024-byte read_exact blocks until EOF. With a finite payload the client keeps the connection open (keep-alive, no half-close), the final block never fills, and the server blocks forever instead of answering.

Impact

Any client that sends Transfer-Encoding: chunked stalls after its first payload. Concrete case: librespeed/speedtest-cli#122 — librespeed-cli v1.0.13+ uploads at 0.55 Mbps against librespeed-rs 1.4.0:

  • The Go client wraps the upload body in a counting io.TeeReader which hides its length, so it sends chunked.
  • Server log from a replica of this body handling: CHUNKED: read 1048837 raw bytes, then EOF/blocked — 1024×1024 payload + 261 bytes of chunk framing; 1048837 is not a multiple of 1024, so the last read_exact(1024) blocks waiting for 763 more bytes that never come.
  • Upload rate = one payload / default 15 s duration = 1 MiB / 15 s ≈ 0.55 Mbps.

Same stall applies to curl -H "Transfer-Encoding: chunked" --data-binary @file and any chunked uploader. Content-Length requests (BodyType::Fixed) work fine.

Suggested fix

Parse chunked encoding in the Chunked branch (RFC 9112 §7.1): read the chunk-size line, the chunk data, and the terminating CRLF per chunk; stop at a 0-size chunk and consume the trailer section. Tokio's BufReader (already in use) provides lines() and read_exact for this.

Client-side note

librespeed/speedtest-cli now sends Content-Length for its fixed-size uploads (librespeed/speedtest-cli#143) as a workaround, but fixing chunked handling here makes the server robust for all clients.

Ngôn ngữ chính
Rust
Star
254
Fork
40
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của librespeed/speedtest-rust

Tất cả issue của librespeed/speedtest-rust

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.