]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
make kwargs always work in AsyncHTTPClient.fetch()
authorliaoxiaorong <xiaorongliao@gmail.com>
Mon, 14 Dec 2015 11:15:03 +0000 (19:15 +0800)
committerliaoxiaorong <xiaorongliao@gmail.com>
Mon, 14 Dec 2015 11:15:03 +0000 (19:15 +0800)
tornado/httpclient.py

index 25b17d039dc89622b4c7ca15120a31a2b26c292f..394c7fb1c504829dc53ca9223e1ebbe1f5a92a36 100644 (file)
@@ -227,6 +227,13 @@ class AsyncHTTPClient(Configurable):
             raise RuntimeError("fetch() called on closed AsyncHTTPClient")
         if not isinstance(request, HTTPRequest):
             request = HTTPRequest(url=request, **kwargs)
+        else:
+            for k, v in kwargs.items():
+                try:
+                    getattr(request, k)
+                except Exception as e:
+                    raise ValueError('HTTPRequest get an unexcept kwags %s' % k)
+                setattr(request, k, v)
         # We may modify this (to add Host, Accept-Encoding, etc),
         # so make sure we don't modify the caller's object.  This is also
         # where normal dicts get converted to HTTPHeaders objects.