Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

HTTP/2 to origin: bodyless response with a header block over 4 KB fails to parse and is sent to the client as 502/500

已关闭
#13,778 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp

调研方向

Start with Http2Stream::send_headers and HttpSM::state_read_server_response_header, then follow HTTPHdr::parse_resp in HdrTSOnly.cc and MIMEScanner::get. Reproduce the bodyless HTTP/2 302 or 204 with an approximately 8.8 KB header block. Done means the large header parses across blocks and the client receives the origin response instead of a 502 or 500.

由索引模型根据 Issue 内容生成。

描述

HTTP/2

Summary

If an HTTP/2 origin sends a bodyless response (HEADERS with END_STREAM) whose header block is larger than one IOBuffer block (about 4 KB), ATS fails to parse it. The client gets a 502 or 500 instead of the origin's response. It mostly shows up on redirects and 204s that carry a large Content-Security-Policy or Set-Cookie.

Cause

  1. Http2Stream::send_headers, which hands a received header to the HttpSM, prints the decoded response header into _receive_buffer one block at a time, adding a block whenever print() doesn't finish. A header of more than about 4 KB therefore spans several blocks, and a field can be split at a block boundary.
  2. With receive_end_stream set on an outbound stream, it then signals VC_EVENT_EOS, not READ_READY or READ_COMPLETE.
  3. HttpSM::state_read_server_response_header handles that EOS by parsing with eof = true. It logs Server closed connection while reading response header at this point, even though nothing closed.
  4. HTTPHdr::parse_resp (HdrTSOnly.cc) loops over the reader one block at a time and passes the same eof flag for every block. When a field is cut at the end of the first block, MIMEScanner::get treats it as the end of input and returns ParseResult::ERROR (unterminated field).
  5. The result is handle_server_setup_error, and the client gets an error. squid-style logs show the origin's real status (a 3xx or 204) next to the 5xx sent to the client, with o_bytes stopping just short of the field that crosses the 4 KB boundary.

Observed / reproduction

Reproduced on a 10.0.x build; HdrTSOnly.cc is identical on master.

  • An HTTP/2 origin returns 302 with no body and a header block of about 8.8 KB, including one long Content-Security-Policy field.
  • A GET through ATS: the origin logs a 302, and the client gets a 502 every time, with o_bytes=202 and the request retried once (two attempts).
  • The same responses had no errors while that origin was reached over HTTP/1.1.
  • In production traffic, one bodyless 3xx endpoint failed 150 of 150 requests.

Suggested fix

Either of these, or both:

  • In HTTPHdr::parse_resp, pass eof only for the last block, when there is no further block to read.
  • In Http2Stream, write the whole decoded header into one block sized to fit it, so a header from an HTTP/2 frame is never split.
主要语言
C++
星标
2k
派生
881
平均合并
3 天 15 小时
30 天内合并 PR
94

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/trafficserver 的其他 Issue

查看 apache/trafficserver 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。