From: liaoxiaorong Date: Mon, 14 Dec 2015 11:15:03 +0000 (+0800) Subject: make kwargs always work in AsyncHTTPClient.fetch() X-Git-Tag: v4.4.0b1~60^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb2633797652389314079e921c8ec05fa211ea3c;p=thirdparty%2Ftornado.git make kwargs always work in AsyncHTTPClient.fetch() --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 25b17d039..394c7fb1c 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -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.