我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用werkzeug.urls.url_decode_stream()。
def _parse_urlencoded(self, stream, mimetype, content_length, options): if self.max_form_memory_size is not None and \ content_length is not None and \ content_length > self.max_form_memory_size: raise exceptions.RequestEntityTooLarge() form = url_decode_stream(stream, self.charset, errors=self.errors, cls=self.cls) return stream, form, self.cls() #: mapping of mimetypes to parsing functions
def test_streamed_url_decoding(self): item1 = u'a' * 100000 item2 = u'b' * 400 string = ('a=%s&b=%s&c=%s' % (item1, item2, item2)).encode('ascii') gen = urls.url_decode_stream(BytesIO(string), limit=len(string), return_iterator=True) self.assert_strict_equal(next(gen), ('a', item1)) self.assert_strict_equal(next(gen), ('b', item2)) self.assert_strict_equal(next(gen), ('c', item2)) self.assert_raises(StopIteration, lambda: next(gen))
def test_stream_decoding_string_fails(self): self.assert_raises(TypeError, urls.url_decode_stream, 'testing')