🐛 Remove Transfer-Encoding header so input is interpreted correctly by flask (#4689)

This commit is contained in:
Moiz Rasheed authored and GitHub committed 2023-01-16 17:59:13 +01:00
1 parent f64ed8aecf
commit 5443b3fe27
2 files changed
+9

No files matched your search

+1
View File
@@ -173,6 +173,7 @@ date of first contribution):
* [Arkadiusz Miśkiewicz](https://github.com/arekm)
* ["tempodat"](https://github.com/tempodat)
* [Frederik Kemner](https://github.com/040medien)
* [Moiz Rasheed](https://github.com/msrasheed)
* [Scott Martin](https://github.com/smartin015)
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
+8
View File
@@ -795,6 +795,14 @@ class WsgiInputContainer:
environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")
if "Content-Length" in request.headers:
environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")
# remove transfer encoding header if chunked, otherwise flask wsgi entrypoint makes input empty
if (
"Transfer-Encoding" in request.headers
and request.headers.get("Transfer-Encoding") == "chunked"
):
request.headers.pop("Transfer-Encoding")
for key, value in request.headers.items():
environ["HTTP_" + key.replace("-", "_").upper()] = value
return environ