# 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))