Beispiel #1
0
    def prepare(self):
        content_type_header = self.request.headers.get('content-type')
        content_type, opts = parse_header_options(content_type_header)
        receiver_class = {
            'multipart/form-data': FormDataReceiver,
        }.get(content_type, DumpingReceiver)

        upload_id = self.get_argument('id', uuid.uuid4().hex)
        try:
            length = int(self.request.headers['content-length'])
        except (ValueError, KeyError):
            pass
        listener = self._pending.get_listener(upload_id)
        self.receiver = receiver_class(listener, **opts)
Beispiel #2
0
def test_parse_header_options(header, expected):
    assert parse_header_options(header) == expected
Beispiel #3
0
 def on_headers_finished(self):
     disposition_header = self.headers['content-disposition']
     disposition, options = parse_header_options(disposition_header)
     if disposition == 'form-data':
         self._current_name, self._current = _choose_input(disposition, options)
         self._parts_received[self._current_name] = self._current
Beispiel #4
0
def test_parse_header_options(header, expected):
    assert parse_header_options(header) == expected