]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
httputil: Downgrade a noisy log line 2580/head
authorBen Darnell <ben@bendarnell.com>
Sat, 2 Feb 2019 17:41:03 +0000 (12:41 -0500)
committerBen Darnell <ben@bendarnell.com>
Sat, 2 Feb 2019 17:55:20 +0000 (12:55 -0500)
Only complain about unsupported content encodings if it's a
content-type we'd otherwise try to parse.

Fixes #2578

tornado/httputil.py

index ec94b1b9db2cedc3afbc91dc1e7f92c54029d966..835327d0a1395966ad55e7355189eace7b068b26 100644 (file)
@@ -777,10 +777,12 @@ def parse_body_arguments(
     and ``files`` parameters are dictionaries that will be updated
     with the parsed contents.
     """
-    if headers and "Content-Encoding" in headers:
-        gen_log.warning("Unsupported Content-Encoding: %s", headers["Content-Encoding"])
-        return
     if content_type.startswith("application/x-www-form-urlencoded"):
+        if headers and "Content-Encoding" in headers:
+            gen_log.warning(
+                "Unsupported Content-Encoding: %s", headers["Content-Encoding"]
+            )
+            return
         try:
             uri_arguments = parse_qs_bytes(native_str(body), keep_blank_values=True)
         except Exception as e:
@@ -790,6 +792,11 @@ def parse_body_arguments(
             if values:
                 arguments.setdefault(name, []).extend(values)
     elif content_type.startswith("multipart/form-data"):
+        if headers and "Content-Encoding" in headers:
+            gen_log.warning(
+                "Unsupported Content-Encoding: %s", headers["Content-Encoding"]
+            )
+            return
         try:
             fields = content_type.split(";")
             for field in fields: