equal
deleted
inserted
replaced
25 |
25 |
26 __docformat__ = "restructuredtext en" |
26 __docformat__ = "restructuredtext en" |
27 |
27 |
28 import tempfile |
28 import tempfile |
29 |
29 |
30 from StringIO import StringIO |
30 from io import BytesIO |
31 |
31 |
32 from six.moves.urllib.parse import parse_qs |
32 from six.moves.urllib.parse import parse_qs |
33 |
33 |
34 from cubicweb.multipart import ( |
34 from cubicweb.multipart import ( |
35 copy_file, parse_form_data, parse_options_header) |
35 copy_file, parse_form_data, parse_options_header) |
56 length = int(environ['CONTENT_LENGTH']) |
56 length = int(environ['CONTENT_LENGTH']) |
57 except (KeyError, ValueError): |
57 except (KeyError, ValueError): |
58 length = 0 |
58 length = 0 |
59 # wsgi.input is not seekable, so copy the request contents to a temporary file |
59 # wsgi.input is not seekable, so copy the request contents to a temporary file |
60 if length < 100000: |
60 if length < 100000: |
61 self.content = StringIO() |
61 self.content = BytesIO() |
62 else: |
62 else: |
63 self.content = tempfile.TemporaryFile() |
63 self.content = tempfile.TemporaryFile() |
64 copy_file(environ['wsgi.input'], self.content, maxread=length) |
64 copy_file(environ['wsgi.input'], self.content, maxread=length) |
65 self.content.seek(0, 0) |
65 self.content.seek(0, 0) |
66 environ['wsgi.input'] = self.content |
66 environ['wsgi.input'] = self.content |