Skip to content
Myr

Guess filename.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Closes #192

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 06b9d15 · Browse files · 2 files+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−2 removed

  • other:+9 added−2 removed

2 files+9 added−2 removed

modified:requests/models.py+3 added-2 removed
26 unmodified lines
27from .exceptions import (28 Timeout, URLRequired, TooManyRedirects, HTTPError, ConnectionError)29from .utils import (30 get_unicode_from_response, stream_decode_response_unicode,31 decode_gzip, stream_decode_gzip)31 decode_gzip, stream_decode_gzip, guess_filename)32333435
309 unmodified lines
345 except AttributeError:346 fields = dict(self.data)347348 for (k, v) in self.files.items():349 fields.update({k: (k, v.read())})349 fields.update({k: (guess_filename(k) or k, v.read())})350351 (body, content_type) = encode_multipart_formdata(fields)352 else:353 pass354 # TODO: Conflict?
240 unmodified lines
modified:requests/utils.py+6 added
18 unmodified lines
1920from urllib2 import parse_http_list as _parse_list_header212223def guess_filename(obj):24 """Tries to guess the filename of the given object."""25 name = getattr(obj, 'name', None)26 if name and name[0] != '<' and name[-1] != '>':27 return name2829# From mitsuhiko/werkzeug (used with permission).30def parse_list_header(value):31 """Parse lists as described by RFC 2068 Section 2.32
337 unmodified lines