Exemplo n.º 1
0
 def test_parse_options_header(self):
     self.assertEqual(
         http.parse_options_header(r'something; foo="other\"thing"'),
         ('something', {'foo': 'other"thing'})
     )
     self.assertEqual(
         http.parse_options_header(
             r'something; foo="other\"thing"; meh=42'
         ),
         ('something', {'foo': 'other"thing', 'meh': '42'})
     )
     self.assertEqual(
         http.parse_options_header(
             r'something; foo="other\"thing"; meh=42; bleh'
         ),
         ('something', {'foo': 'other"thing', 'meh': '42', 'bleh': None})
     )
     self.assertEqual(
         http.parse_options_header(
             'something; foo="other;thing"; meh=42; bleh'
         ),
         ('something', {'foo': 'other;thing', 'meh': '42', 'bleh': None})
     )
     self.assertEqual(
         http.parse_options_header(
             'something; foo="otherthing"; meh=; bleh'
         ),
         ('something', {'foo': 'otherthing', 'meh': None, 'bleh': None})
     )
Exemplo n.º 2
0
 def _get_mimetype_params(self):
     def on_update(d):
         self.headers['Content-Type'] = dump_options_header(
             self.mimetype, d
         )
     d = parse_options_header(self.headers.get('content-type', ''))[1]
     return CallbackDict(d, on_update)
Exemplo n.º 3
0
 def _get_mimetype_params(self):
     def on_update(d):
         self.headers['Content-Type'] = dump_options_header(
             self.mimetype, d
         )
     d = parse_options_header(self.headers.get('content-type', ''))[1]
     return CallbackDict(d, on_update)
Exemplo n.º 4
0
    def _load_form_data(self):
        """Method used internally to retrieve submitted data.  After calling
        this sets `form` and `files` on the request object to multi dicts
        filled with the incoming form data.  As a matter of fact the input
        stream will be empty afterwards.  You can also call this method to
        force the parsing of the form data.
        """
        # abort early if we have already consumed the stream
        if 'form' in self.__dict__:
            return

        _assert_not_shallow(self)

        if self.want_form_data_parsed:
            content_type = self.environ.get('CONTENT_TYPE', '')
            content_length = get_content_length(self.environ)
            mimetype, options = parse_options_header(content_type)
            parser = self.make_form_data_parser()
            data = parser.parse(self._get_stream_for_parsing(), mimetype,
                                content_length, options)
        else:
            data = (self.stream, self.parameter_storage_class(),
                    self.parameter_storage_class())

        # inject the values into the instance dict so that we bypass
        # our cached_property non-data descriptor.
        d = self.__dict__
        d['stream'], d['form'], d['files'] = data
Exemplo n.º 5
0
 def _parse_content_type(self):
     if not hasattr(self, '_parsed_content_type'):
         self._parsed_content_type = parse_options_header(
             self.environ.get('CONTENT_TYPE', ''))