Skip to content
Myr

freaking string replace

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 · parent f66eafd · Browse files · 1 file+19 added−19 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+19 added−19 removed

  • other:+19 added−19 removed

1 file+19 added−19 removed

modified:requests/core.py+19 added-19 removed
24 unmodified lines
25AUTOAUTHS = []262728class _Request(urllib2.Request):29 """Hidden wrapper around the urllib2.Request object. Allows for manual29 """Hidden wrapper around the urllib2.Request object. Allows for manual30 setting of HTTP methods.31 """32 33 def __init__(self, url, data=None, headers={}, origin_req_host=None, unverifiable=False, method=None):
7 unmodified lines
41 return urllib2.Request.get_method(self)424344class Request(object):45 """The :class:`Request` object. It carries out all functionality of45 """The :class:`Request` object. It carries out all functionality of46 Requests. Recommended interface is with the Requests functions.47 """48 49 _METHODS = ('GET', 'HEAD', 'PUT', 'POST', 'DELETE')
25 unmodified lines
75 object.__setattr__(self, name, value)76 77 78 def _checks(self):79 """Deterministic checks for consistiency."""79 """Deterministic checks for consistiency."""8081 if not self.url:82 raise URLRequired8384 85 def _get_opener(self):86 """Creates appropriate opener object for urllib2."""86 """Creates appropriate opener object for urllib2."""87 88 if self.auth:8990 # create a password manager
9 unmodified lines
100 return urllib2.urlopen101102 103 def send(self, anyway=False):104 """Sends the request. Returns True of successfull, false if not.104 """Sends the request. Returns True of successfull, false if not.105 If there was an HTTPError during transmission,106 self.response.status_code will contain the HTTPError code.107108 Once a request is successfully sent, `sent` will equal True.
94 unmodified lines
203 return success204 205206class Response(object):207 """The :class:`Request` object. All :class:`Request` objects contain a207 """The :class:`Request` object. All :class:`Request` objects contain a208 :class:`Request.response <response>` attribute, which is an instance of209 this class.210 """211
10 unmodified lines
222 return repr223224 225class AuthObject(object):226 """The :class:`AuthObject` is a simple HTTP Authentication token. When226 """The :class:`AuthObject` is a simple HTTP Authentication token. When227 given to a Requests function, it enables Basic HTTP Authentication for that228 Request. You can also enable Authorization for domain realms with AutoAuth.229 See AutoAuth for more details.230
7 unmodified lines
238239240241def get(url, params={}, headers={}, auth=None):242 """Sends a GET request. Returns :class:`Response` object.242 """Sends a GET request. Returns :class:`Response` object.243244 :param url: URL for the new :class:`Request` object.245 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.246 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
13 unmodified lines
260 return r.response261262263def head(url, params={}, headers={}, auth=None):264 """Sends a HEAD request. Returns :class:`Response` object.264 """Sends a HEAD request. Returns :class:`Response` object.265266 :param url: URL for the new :class:`Request` object.267 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.268 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
14 unmodified lines
283 return r.response284285286def post(url, data={}, headers={}, auth=None):287 """Sends a POST request. Returns :class:`Response` object.287 """Sends a POST request. Returns :class:`Response` object.288289 :param url: URL for the new :class:`Request` object.290 :param data: (optional) Dictionary of POST Data to send with the :class:`Request`.291 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
14 unmodified lines
306 return r.response307 308 309def put(url, data='', headers={}, auth=None):310 """Sends a PUT request. Returns :class:`Response` object.310 """Sends a PUT request. Returns :class:`Response` object.311312 :param url: URL for the new :class:`Request` object.313 :param data: (optional) Bytes of PUT Data to send with the :class:`Request`.314 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
14 unmodified lines
329 return r.response330331 332def delete(url, params={}, headers={}, auth=None):333 """Sends a DELETE request. Returns :class:`Response` object.333 """Sends a DELETE request. Returns :class:`Response` object.334335 :param url: URL for the new :class:`Request` object.336 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.337 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
14 unmodified lines
352 return r.response353354355def add_autoauth(url, authobject):356 """Registers given AuthObject to given URL domain. for auto-activation.356 """Registers given AuthObject to given URL domain. for auto-activation.357 Once a URL is registered with an AuthObject, the configured HTTP358 Authentication will be used for all requests with URLS containing the given359 URL string.360
12 unmodified lines
373 AUTOAUTHS.append((url, authobject))374375376def _detect_auth(url, auth):377 """Returns registered AuthObject for given url if available, defaulting to377 """Returns registered AuthObject for given url if available, defaulting to378 given AuthObject.379 """380381 return _get_autoauth(url) if not auth else auth382383 384def _get_autoauth(url):385 """Returns registered AuthObject for given url if available."""385 """Returns registered AuthObject for given url if available."""386 387 for (autoauth_url, auth) in AUTOAUTHS:388 if autoauth_url in url: 389 return auth390 391 return None392393class RequestException(Exception):394 """There was an ambiguous exception that occured while handling your request."""394 """There was an ambiguous exception that occured while handling your request."""395396class AuthenticationError(RequestException):397 """The authentication credentials provided were invalid."""397 """The authentication credentials provided were invalid."""398 399class URLRequired(RequestException):400 """A valid URL is required to make a request."""400 """A valid URL is required to make a request."""401 402class InvalidMethod(RequestException):403 """An inappropriate method was attempted."""403 """An inappropriate method was attempted."""