Skip to content
Myr

Merge remote-tracking branch 'origin/develop' into develop

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parents fe7348c, e627c1f · Browse files · 4 files+63 added−1 removed
This commit

State

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

Diff stats

4 files+63 added−1 removed

  • tests:+31 added−0 removed
  • other:+32 added−1 removed

4 files+63 added−1 removed

modified:docs/user/quickstart.rst+28 added
220 unmodified lines
221 },222 "data": ""223 }224225Sending strings to be received as files::226227 >>> url = 'http://httpbin.org/post'228 >>> files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')} 229230 >>> r = requests.post(url, files=files)231 >>> r.text232 {233 "origin": "179.13.100.4",234 "files": {235 "file": "some,data,to,send\\nanother,row,to,send\\n"236 },237 "form": {},238 "url": "http://httpbin.org/post",239 "args": {},240 "headers": {241 "Content-Length": "216",242 "Accept-Encoding": "identity, deflate, compress, gzip",243 "Connection": "keep-alive",244 "Accept": "*/*",245 "User-Agent": "python-requests/0.11.1",246 "Host": "httpbin.org", 247 "Content-Type": "multipart/form-data; boundary=127.0.0.1.502.41433.1335385481.788.1"248 }, 249 "json": null,250 "data": ""251 }252253254Response Status Codes255---------------------256257We can check the response status code::
203 unmodified lines
modified:requests/models.py+3 added-1 removed
31 unmodified lines
32 stream_decode_response_unicode, get_netrc_auth, get_environ_proxies,33 DEFAULT_CA_BUNDLE_PATH)34from .compat import (35 cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,36 is_py2)36 StringIO, is_py2)3738# Import chardet if it is available.39try:40 import chardet
307 unmodified lines
348 fn, fp = v349 else:350 fn = guess_filename(v) or k351 fp = v352 if isinstance(fp, (bytes, str)):353 fp = StringIO(fp)354 fields.update({k: (fn, fp.read())})355356 (body, content_type) = encode_multipart_formdata(fields)357
485 unmodified lines
modified:tests/test_requests.py+31 added
327 unmodified lines
328 headers={'User-Agent': 'requests-tests'})329330 self.assertEqual(post2.status_code, 200)331332 def test_POSTBIN_GET_POST_FILES_STRINGS(self):333334 for service in SERVICES:335336 url = service('post')337338 post1 = post(url, files={'fname.txt': 'fdata'})339 self.assertEqual(post1.status_code, 200)340341 post2 = post(url, files={'fname.txt': 'fdata', 'fname2.txt':'more fdata'})342 self.assertEqual(post2.status_code, 200)343344 post3 = post(url, files={'fname.txt': 'fdata', 'fname2.txt':open(__file__,'rb')})345 self.assertEqual(post3.status_code, 200)346347 post4 = post(url, files={'fname.txt': 'fdata'})348 self.assertEqual(post4.status_code, 200)349350 post5 = post(url, files={'file': ('file.txt', 'more fdata')})351 self.assertEqual(post5.status_code, 200)352353 post6 = post(url, files={'fname.txt': '\xe9'})354 self.assertEqual(post6.status_code, 200)355356 post7 = post(url, files={'fname.txt': 'fdata to verify'})357 rbody = json.loads(post7.text)358 self.assertTrue(rbody.get('files', None))359 self.assertTrue(rbody['files'].get('fname.txt'), None)360 self.assertEqual(rbody['files']['fname.txt'], 'fdata to verify')361362363 def test_nonzero_evaluation(self):364365 for service in SERVICES:366
541 unmodified lines
modified:AUTHORS.rst+1 added
96 unmodified lines
97- Jonty Wareing <jonty@jonty.co.uk>98- Shivaram Lingamneni99- Miguel Turner100- Rohan Jain (crodjer)101- Justin Barber <barber.justin@gmail.com>