Skip to content
Myr

Merge branch 'master' into master

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

authored by David Poole · committed by GitHub · parents 1e46cbb, 24092b1 · Browse files · 7 files+56 added−25 removed
This commit

State

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

Diff stats

7 files+56 added−25 removed

  • tests:+6 added−1 removed
  • other:+50 added−24 removed

7 files+56 added−25 removed

modified:docs/user/quickstart.rst+1 added
279 unmodified lines
280 >>> payload = {'some': 'data'}281282 >>> r = requests.post(url, json=payload)283284Note, the ``json`` parameter is ignored if either ``data`` or ``files`` is passed.285286POST a Multipart-Encoded File287-----------------------------288
268 unmodified lines
modified:docs/api.rst+1 added-11 removed
107 unmodified lines
108------------------109110.. autoclass:: requests.codes111112::112.. automodule:: requests.status_codes113114 >>> requests.codes['temporary_redirect']115 307114117 >>> requests.codes.teapot118 418119120 >>> requests.codes['\o/']121 200122123124115Migrating to 1.x116----------------117118This section details the main differences between 0.x and 1.x and is meant
142 unmodified lines
modified:requests/models.py+2 added-2 removed
684 unmodified lines
685 return self.iter_content(128)686687 @property688 def ok(self):689 """Returns True if :attr:`status_code` is less than 400.689 """Returns True if :attr:`status_code` is less than 400, False if not.690691 This attribute checks if the status code of the response is between692 400 and 600 to see if there was a client error or a server error. If693 the status code, is between 200 and 400, this will return True. This693 the status code is between 200 and 400, this will return True. This694 is **not** a check to see if the response code is ``200 OK``.695 """696 try:697 self.raise_for_status()
251 unmodified lines
modified:requests/status_codes.py+33 added-5 removed
1# -*- coding: utf-8 -*-23"""4The ``codes`` object defines a mapping from common names for HTTP statuses5to their numerical codes, accessible either as attributes or as dictionary6items.78>>> requests.codes['temporary_redirect']930710>>> requests.codes.teapot1141812>>> requests.codes['\o/']132001415Some codes have multiple names, and both upper- and lower-case versions of16the names are allowed. For example, ``codes.ok``, ``codes.OK``, and17``codes.okay`` all correspond to the HTTP status code 200.18"""1920from .structures import LookupDict2122_codes = {23
76 unmodified lines
100}101102codes = LookupDict(name='status_codes')103104def _init():87for code, titles in _codes.items():88 for title in titles:89 setattr(codes, title, code)90 if not title.startswith(('\\', '/')):91 setattr(codes, title.upper(), code)105 for code, titles in _codes.items():106 for title in titles:107 setattr(codes, title, code)108 if not title.startswith(('\\', '/')):109 setattr(codes, title.upper(), code)110111 def doc(code):112 names = ', '.join('``%s``' % n for n in _codes[code])113 return '* %d: %s' % (code, names)114115 global __doc__116 __doc__ = (__doc__ + '\n' +117 '\n'.join(doc(code) for code in sorted(_codes)))118119_init()
modified:requests/utils.py+12 added-6 removed
43 unmodified lines
44if sys.platform == 'win32':45 # provide a proxy_bypass version on Windows without DNS lookups4647 def proxy_bypass_registry(host):48 if is_py3:49 import winreg50 else:51 import _winreg as winreg48 try:49 if is_py3:50 import winreg51 else:52 import _winreg as winreg53 except ImportError:54 return False5556 try:57 internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,58 r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')59 # ProxyEnable could be REG_SZ or REG_DWORD, normalizing it55 proxyEnable = winreg.QueryValueEx(internetSettings,56 'ProxyEnable')[0]60 proxyEnable = int(winreg.QueryValueEx(internetSettings,61 'ProxyEnable')[0])62 # ProxyOverride is almost always a string63 proxyOverride = winreg.QueryValueEx(internetSettings,64 'ProxyOverride')[0]65 except OSError:66 return False
882 unmodified lines
modified:tests/test_utils.py+6 added-1 removed
3 unmodified lines
4import copy5import filecmp6from io import BytesIO7import zipfile8from collections import deque910import pytest11from requests import compat12from requests.cookies import RequestsCookieJar
653 unmodified lines
666 def Close(self):667 pass668669 ie_settings = RegHandle()670 proxyEnableValues = deque([1, "1"])671672 def OpenKey(key, subkey):673 return ie_settings674675 def QueryValueEx(key, value_name):676 if key is ie_settings:677 if value_name == 'ProxyEnable':676 return [1]678 # this could be a string (REG_SZ) or a 32-bit number (REG_DWORD)679 proxyEnableValues.rotate()680 return [proxyEnableValues[0]]681 elif value_name == 'ProxyOverride':682 return [override]683684 monkeypatch.setenv('http_proxy', '')
2 unmodified lines
687 monkeypatch.setenv('no_proxy', '')688 monkeypatch.setenv('NO_PROXY', '')689 monkeypatch.setattr(winreg, 'OpenKey', OpenKey)690 monkeypatch.setattr(winreg, 'QueryValueEx', QueryValueEx)691 assert should_bypass_proxies(url, None) == expected692693694@pytest.mark.parametrize(695 'env_name, value', (
22 unmodified lines
modified:HISTORY.rst+1 added
14 unmodified lines
1516- Parsing empty ``Link`` headers with ``parse_header_links()`` no longer return one bogus entry17- Fixed issue where loading the default certificate bundle from a zip archive18 would raise an ``IOError``19- Fixed issue with unexpected ``ImportError`` on windows system which do not support ``winreg`` module2021222.18.4 (2017-08-15)23+++++++++++++++++++
1520 unmodified lines