fix(proxy): ignore empty body payloads in HTTP/1 upstream writes - #976
fix(proxy): ignore empty body payloads in HTTP/1 upstream writes#976Curious-r wants to merge 1 commit into
Conversation
ba4de7b to
8650d51
Compare
|
Sorry, I missed #936 before opening this. Looking at the patches, though, I don't think this is a duplicate — they seem complementary. #936 hardens This PR works at the HTTP/1 proxy adapter instead: Given the different layers, I think it may make sense to land both: #936 protects the writer API more broadly, while this change keeps the generic proxy task-to-H1 translation from treating an empty EOS signal as application data. |
Summary
Fix a spurious HTTP/1 warning when an empty final body task follows a fully written
Content-Lengthbody. The upstream sink now skips empty payloads in bothBodyandUpgradedBody, whilefinish_body()still handles final framing andContent-Lengthvalidation. Non-empty data after the body is finished continues to trigger the warning.Added regression tests for
Content-Lengthand chunked bodies to ensure empty final tasks don't affect wire framing or produce duplicate chunk terminators.Validated with
cargo test -p pingora-proxy --lib,cargo clippy -p pingora-proxy --lib --tests -- -D warnings, andcargo fmt --all -- --check.Background:
When using a Pingora-based reverse proxy for my Matrix homeserver, I noticed that it produced a large number of warnings like:
After enabling DEBUG logging, the warning could be reproduced on normal Matrix federation requests. The relevant sequence was:
This shows that the warning is triggered by an empty body event arriving after the complete
Content-Lengthbody has already been written. Since empty payloads do not carry any data andfinish_body()already handles the end-of-body framing, the empty buffer should be ignored rather than passed towrite_body().