fix(web): always drain visit request body to keep keep-alive connections aligned
This commit is contained in:
1 parent
a3e7589ad3
commit
e3bd2e601b
2 files changed
+33
-4
No files matched your search
@@ -323,10 +323,9 @@ border-color:#3a2c22;color:#f3e9dc}button{background:#e9b97c;color:#2a1a10}}
|
||||
return
|
||||
|
||||
path_value = _param(query, "path", "")
|
||||
if not path_value:
|
||||
body = self._read_small_body()
|
||||
if body:
|
||||
path_value = _json_path(body)
|
||||
body = self._read_small_body()
|
||||
if not path_value and body:
|
||||
path_value = _json_path(body)
|
||||
|
||||
user_agent = self.headers.get("User-Agent")
|
||||
if not track.count_bots and is_bot(user_agent):
|
||||
@@ -360,6 +359,8 @@ border-color:#3a2c22;color:#f3e9dc}button{background:#e9b97c;color:#2a1a10}}
|
||||
if length <= 0:
|
||||
return b""
|
||||
if length > VISIT_BODY_LIMIT:
|
||||
# 不读取超长请求体,直接关闭连接,避免 keep-alive 上残留字节错位。
|
||||
self.close_connection = True
|
||||
raise ApiError(HTTPStatus.BAD_REQUEST, "bad_request", "请求体过大")
|
||||
return self.rfile.read(length)
|
||||
|
||||
|
||||
Reference in new issue
Block a user