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
Provenance
- Commit
d1dc6aa- Tree
df448e6- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
f66eafd
1 file changed+19 added−19 removed
modified:requests/core.py+19 added-19 removed
24 unmodified lines25 AUTOAUTHS = []26 27 28 class _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 lines41 return urllib2.Request.get_method(self)42 43 44 class 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 lines75 object.__setattr__(self, name, value)76 77 78 def _checks(self):79- """Deterministic checks for consistiency."""79+ """Deterministic checks for consistiency."""80 81 if not self.url:82 raise URLRequired83 84 85 def _get_opener(self):86- """Creates appropriate opener object for urllib2."""86+ """Creates appropriate opener object for urllib2."""87 88 if self.auth:89 90 # create a password manager9 unmodified lines100 return urllib2.urlopen101 102 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.107 108 Once a request is successfully sent, `sent` will equal True.94 unmodified lines203 return success204 205 206 class 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 lines222 return repr223 224 225 class 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 lines238 239 240 241 def get(url, params={}, headers={}, auth=None):242- """Sends a GET request. Returns :class:`Response` object.242+ """Sends a GET request. Returns :class:`Response` object.243 244 :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 lines260 return r.response261 262 263 def head(url, params={}, headers={}, auth=None):264- """Sends a HEAD request. Returns :class:`Response` object.264+ """Sends a HEAD request. Returns :class:`Response` object.265 266 :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 lines283 return r.response284 285 286 def post(url, data={}, headers={}, auth=None):287- """Sends a POST request. Returns :class:`Response` object.287+ """Sends a POST request. Returns :class:`Response` object.288 289 :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 lines306 return r.response307 308 309 def put(url, data='', headers={}, auth=None):310- """Sends a PUT request. Returns :class:`Response` object.310+ """Sends a PUT request. Returns :class:`Response` object.311 312 :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 lines329 return r.response330 331 332 def delete(url, params={}, headers={}, auth=None):333- """Sends a DELETE request. Returns :class:`Response` object.333+ """Sends a DELETE request. Returns :class:`Response` object.334 335 :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 lines352 return r.response353 354 355 def 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 lines373 AUTOAUTHS.append((url, authobject))374 375 376 def _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 """380 381 return _get_autoauth(url) if not auth else auth382 383 384 def _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 None392 393 class 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."""395 396 class AuthenticationError(RequestException):397- """The authentication credentials provided were invalid."""397+ """The authentication credentials provided were invalid."""398 399 class URLRequired(RequestException):400- """A valid URL is required to make a request."""400+ """A valid URL is required to make a request."""401 402 class InvalidMethod(RequestException):403- """An inappropriate method was attempted."""403+ """An inappropriate method was attempted."""