Ejemplo n.º 1
0
 def on_headers_complete(self):
     disposition_type, params = parse_content_disposition(
         self._current_headers.get(b'Content-Disposition'))
     if not disposition_type:
         return
     self._current_params = params
     if b'Content-Type' in self._current_headers:
         self._current = BytesIO()
         self._current.filename = extract_filename(params)
         self._current.content_type = self._current_headers[b'Content-Type']
         self._current.params = params
     else:
         self._current = ''
Ejemplo n.º 2
0
def test_extract_filename_without_filename():
    assert extract_filename({}) == ''
Ejemplo n.º 3
0
def test_extract_filename_star_without_quotes():
    assert extract_filename({b'filename*':
                             "foo-ä-€.html".encode()}) == "foo-ä-€.html"
Ejemplo n.º 4
0
def test_extract_filename_star_without_quotes_but_filename():
    assert extract_filename({
        b'filename*': "foo-ä-€.html".encode(),
        b'filename': b"baz.quux"
    }) == "baz.quux"
Ejemplo n.º 5
0
def test_extract_filename_star_no_encoding():
    assert extract_filename({b'filename*':
                             "''foo-ä-€.html".encode()}) == "foo-ä-€.html"
Ejemplo n.º 6
0
def test_extract_filename_star_no_encoding_but_filename():
    assert extract_filename({
        b'filename*': "''foo-ä-€.html".encode(),
        b'filename': b"baz.quux"
    }) == "baz.quux"
Ejemplo n.º 7
0
def test_extract_filename_star_latin1_with_accent():
    assert extract_filename(
        {b'filename*':
         "iso-8859-1''foo-ä.html".encode('latin1')}) == 'foo-ä.html'
Ejemplo n.º 8
0
def test_extract_filename_star_utf8_with_accent():
    assert extract_filename({b'filename*':
                             "UTF-8''foo-ä-€.html".encode()}) == 'foo-ä-€.html'
Ejemplo n.º 9
0
def test_extract_filename():
    assert extract_filename({b'filename': b'foo.bar'}) == 'foo.bar'
Ejemplo n.º 10
0
def test_extract_filename_star_wrong_encoding():
    assert extract_filename({b'filename*': b"unknow''foo.bar"}) == 'foo.bar'
Ejemplo n.º 11
0
def test_extract_filename_and_star_wrong_encoding():
    assert extract_filename({
        b'filename*': b"unknown''foo.bar",
        b'filename': b"baz.quux"
    }) == 'baz.quux'
Ejemplo n.º 12
0
def test_extract_filename_and_star():
    assert extract_filename({
        b'filename*': b"utf-8''foo.bar",
        b'filename': b"baz.quux"
    }) == 'foo.bar'
Ejemplo n.º 13
0
def test_extract_filename_star():
    assert extract_filename({b'filename*': b"utf-8''foo.bar"}) == 'foo.bar'