From: Ben Darnell Date: Thu, 17 Jul 2014 00:16:38 +0000 (-0400) Subject: Merge pull request #1116 from homm/curl-put-redirects X-Git-Tag: v4.1.0b1~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52b6d1d1c3dd9da853b139addcdaacb6eb8e6b69;p=thirdparty%2Ftornado.git Merge pull request #1116 from homm/curl-put-redirects make IOCMD_RESTARTREAD available for PUT requests --- 52b6d1d1c3dd9da853b139addcdaacb6eb8e6b69 diff --cc tornado/curl_httpclient.py index 531818851,a46ce4055..a09732330 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@@ -387,18 -404,13 +387,18 @@@ def _curl_setup_request(curl, request, # Handle curl's cryptic options for every individual HTTP method if request.method in ("POST", "PUT"): + if request.body is None: + raise AssertionError( + 'Body must not be empty for "%s" request' + % request.method) + request_buffer = BytesIO(utf8(request.body)) + def ioctl(cmd): + if cmd == curl.IOCMD_RESTARTREAD: + request_buffer.seek(0) curl.setopt(pycurl.READFUNCTION, request_buffer.read) + curl.setopt(pycurl.IOCTLFUNCTION, ioctl) if request.method == "POST": - def ioctl(cmd): - if cmd == curl.IOCMD_RESTARTREAD: - request_buffer.seek(0) - curl.setopt(pycurl.IOCTLFUNCTION, ioctl) curl.setopt(pycurl.POSTFIELDSIZE, len(request.body)) else: curl.setopt(pycurl.INFILESIZE, len(request.body))