Skip to content
Myr

Need to write tests but this looks good so far.

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

authored by Ian Cordasco · committed by Ian Cordasco · parent 664880d · Browse files · 1 file+24 added−17 removed
This commit

State

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

Diff stats

1 file+24 added−17 removed

  • other:+24 added−17 removed

1 file+24 added−17 removed

modified:requests/models.py+24 added-17 removed
35 unmodified lines
3637REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)38CONTENT_CHUNK_SIZE = 10 * 1024394041class Request(object):41 """The :class:`Request <Request>` object. It carries out all functionality of42 Requests. Recommended interface is with the Requests functions.42 """The :class:`Request <Request>` object. It carries out all functionality43 of Requests. Recommended interface is with the Requests functions.44 """4546 def __init__(self,47 url=None,
263 unmodified lines
311 2-tuples. Order is retained if data is a list of 2-tuples but abritrary312 if parameters are supplied as a dict.313 """314314 if isinstance(data, bytes):315 if isinstance(data, (str, bytes)):316 return data316 if isinstance(data, str):317 return data317 elif hasattr(data, 'read'):318 return data319 elif hasattr(data, '__iter__'):320 try:321 dict(data)322 except ValueError:324 raise ValueError('Unable to encode lists with elements that are not 2-tuples.')323 raise ValueError('Unable to encode lists with elements that '324 'are not 2-tuples.')325326 params = list(data.items() if isinstance(data, dict) else data)327 result = []328 for k, vs in params:
10 unmodified lines
339 if (not files) or isinstance(self.data, str):340 return None341342 try:343 fields = self.data.copy()343 fields = self.data.items()344 except AttributeError:345 fields = dict(self.data)345 fields = dict(self.data).items()346347 for (k, v) in list(files.items()):347 if isinstance(files, dict):348 files = files.items()349350 for (k, v) in files:351 # support for explicit filename352 if isinstance(v, (tuple, list)):353 fn, fp = v354 else:355 fn = guess_filename(v) or k356 fp = v357 if isinstance(fp, (bytes, str)):358 fp = StringIO(fp)356 fields.update({k: (fn, fp.read())})359 fields.append((k, (fn, fp.read())))360358 for field in fields:359 if isinstance(fields[field], float):360 fields[field] = str(fields[field])361 if isinstance(fields[field], list):362 newvalue = ', '.join(fields[field])363 fields[field] = newvalue364 361 new_fields = []362 for field, val in fields:363 if isinstance(val, float):364 new_fields.append((field, str(val)))365 elif isinstance(val, list):366 newvalue = ', '.join(val)367 new_fields.append((field, newvalue))368 else:369 new_fields.append((field, val))370 fields = new_fields371372 (body, content_type) = encode_multipart_formdata(fields)373374 return (body, content_type)375
473 unmodified lines