ledgetech / ledgetech/lua-resty-http

res:read_body() unable to read chunksize

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

Nobody has claimed this yet.

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

Description

响应头包含不符合规范的头信息,导致chunked的响应体获取失败

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Date: Wed, 24 Apr 2024 06:32:55 GMT
Vary: Accept-Encoding
Sso-Version: 1.0
Expires: Wed, 24 Apr 2024 06:32:55 GMT
Cache-Control: max-age=0
Access-Control-Allow-Origin: http://xxx.aaa.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Location,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Oidc-Temp-Ticket,Sec-Fetch-Dest,Sec-Fetch-Mode,
Sec-Fetch-Site,TE:
Access-Control-Expose-Headers: Location,Set-Cookie,Content-Type,Content-Length,Content-Range,Oidc-Temp-Ticket
Access-Control-Max-Age: 1728000

在执行_chunked_body_reader时,从sock中读取的第一行数据是:Access-Control-Expose-Headers: Location,Set-Cookie,Content-Type,Content-Length,Content-Range,Oidc-Temp-Ticket

在使用reader读取响应体时,报unable to read chunksize 错误

怀疑是在_receive_headers的时候从sock读取响应头到 Sec-Fetch-Site,TE: 行,发生了错误,结束了读取。 在读取响应体时从异常头的下一行开始读取

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.

Research direction

Start with res:read_body(), then inspect _chunked_body_reader and _receive_headers, focusing on how sock reads the malformed Sec-Fetch-Site,TE: header line. Reproduce the failure using the response headers in the issue and verify that reading the chunked response body no longer reports an unable to read chunksize error.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.