bug: wrong trailer format parsing

Open
#295 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
lua
Domain
api, networking

Research direction

Inspect the chunked-body trailer parsing in lib/resty/http.lua around lines 486-489 and the existing cases in t/04-trailers.t around lines 79-86. Run the trailer tests first, then verify parsing against the HTTP Trailer format shown in the issue. Done means the first trailer header is preserved rather than losing its first two characters.

Written by the indexing model from the issue text.

Description

The trailer headers should be in the following format:

...<body>...
0\r\n
Trailer-Header-A: foo\r\n
...
\r\n

However, the code thought there is an extra \r\n between 0\r\n and Trailer-Header-A: foo\r\n, so it consumes two more chars from the first header at the end of chunked body parsing, then the first parsed header becomes a truncated version: ailer-Header-A: foo\r\n.

https://github.com/ledgetech/lua-resty-http/blob/4ab4269cf442ba52507aa2c718f606054452fcad/lib/resty/http.lua#L486-L489

https://github.com/ledgetech/lua-resty-http/blob/4ab4269cf442ba52507aa2c718f606054452fcad/t/04-trailers.t#L79-L86

Dominant language
Lua
Stars
2.1k
Forks
630
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ledgetech/lua-resty-http

All issues in ledgetech/lua-resty-http

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.