Skip to content

Commit 47d294f

Browse files
fix: allow 'Content-Length' = "0"
Shelly devices send a 'Content-Length' header with a value of "0". Allow this as this also means there is not a request body. In addition give a bit more detail in the error message. Closes: #1616
1 parent bb78c20 commit 47d294f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/websockets/http11.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def parse(
159159
raise NotImplementedError("transfer codings aren't supported")
160160

161161
if "Content-Length" in headers:
162-
raise ValueError("unsupported request body")
162+
content_length = headers["Content-Length"]
163+
if content_length != "0":
164+
raise ValueError(
165+
f"unsupported request body as 'Content-Length' is non-zero: {content_length}"
166+
)
163167

164168
return cls(path, headers)
165169

0 commit comments

Comments
 (0)