Skip to content
Myr

Documentation update.

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 4018276 · Browse files · 1 file+63 added−14 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+63 added−14 removed

  • other:+63 added−14 removed

1 file+63 added−14 removed

modified:requests/core.py+63 added-14 removed
24 unmodified lines
25AUTOAUTHS = []262728class _Request(urllib2.Request):29 def __init__(self, url, data=None, headers={},30 origin_req_host=None, unverifiable=False, method=None):31 urllib2.Request.__init__(self, url, data, headers, origin_req_host, unverifiable)32 self.method = method29 """Hidden wrapper around the urllib2.Request object. Allows for manual30 setting of HTTP methods.31 """32 33 def __init__(self, url,34 data=None, headers={}, origin_req_host=None,35 unverifiable=False, method=None):36 urllib2.Request.__init__( self, url, data, headers, origin_req_host,37 unverifiable)38 self.method = method3934 def get_method(self):35 if self.method:36 return self.method40 def get_method(self):41 if self.method:42 return self.method4338 return urllib2.Request.get_method(self)44 return urllib2.Request.get_method(self)454647class Request(object):42 """The :class:`Request` object. It's awesome.48 """The :class:`Request` object. It carries out all functionality of49 Requests. Recommended interface is with the Requests functions.5051 52 """53 54 _METHODS = ('GET', 'HEAD', 'PUT', 'POST', 'DELETE')55
42 unmodified lines
98 return urllib2.urlopen99100 101 def send(self, anyway=False):93 """Sends the request. 102 """Sends the request. Returns True of successfull, false if not.103 If there was an HTTPError during transmission,104 self.response.status_code will contain the HTTPError code.105106 Once a request is successfully sent, `sent` will equal True.107 95 :param anyway: If True, request will be sent, even if it has already been sent.108 :param anyway: If True, request will be sent, even if it has109 already been sent.110 """111 self._checks()112113 success = False
87 unmodified lines
201 return success202 203204class Response(object):191 """The :class:`Request` object. It's awesome.205 """The :class:`Request` object. All :class:`Request` objects contain a206 :class:`Request.response <response>` attribute, which is an instance of207 this class.208 """209210 def __init__(self):211 self.content = None
1 unmodified line
213 self.headers = dict()214215 216class AuthObject(object):201 """The :class:`AuthObject` is a simple HTTP Authentication token.217 """The :class:`AuthObject` is a simple HTTP Authentication token. When218 given to a Requests function, it enables Basic HTTP Authentication for that219 Request. You can also enable Authorization for domain realms with AutoAuth.220 See AutoAuth for more details.s221 222 :param username: Username to authenticate with.223 :param password: Password for given username.205 """224 """225 226 def __init__(self, username, password):227 self.username = username228 self.password = password
1 unmodified line
230231232def get(url, params={}, headers={}, auth=None):233 """Sends a GET request. Returns :class:`Response` object.234235 :param url: URL for the new :class:`Request` object.236 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.237 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.238 :param auth: (optional) AuthObject to enable Basic HTTP Auth.239 """240 241 r = Request()242 243 r.method = 'GET'244 r.url = url
7 unmodified lines
252253254def head(url, params={}, headers={}, auth=None):255 """Sends a HEAD request. Returns :class:`Response` object.256257 :param url: URL for the new :class:`Request` object.258 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.259 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.260 :param auth: (optional) AuthObject to enable Basic HTTP Auth.261 """262 263 r = Request()264 265 r.method = 'HEAD'266 r.url = url
8 unmodified lines
275276277def post(url, data={}, headers={}, auth=None):278 """Sends a POST request. Returns :class:`Response` object.279280 :param url: URL for the new :class:`Request` object.281 :param data: (optional) Dictionary of POST Data to send with the :class:`Request`.282 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.283 :param auth: (optional) AuthObject to enable Basic HTTP Auth.284 """285 286 r = Request()287288 r.url = url289 r.method = 'POST'
8 unmodified lines
298 299 300def put(url, data='', headers={}, auth=None):301 """Sends a PUT request. Returns :class:`Response` object.302303 :param url: URL for the new :class:`Request` object.304 :param data: (optional) Bytes of PUT Data to send with the :class:`Request`.305 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.306 :param auth: (optional) AuthObject to enable Basic HTTP Auth.307 """308 309 r = Request()310311 r.url = url312 r.method = 'PUT'
8 unmodified lines
321322 323def delete(url, params={}, headers={}, auth=None):324 """Sends a DELETE request. Returns :class:`Response` object.325326 :param url: URL for the new :class:`Request` object.327 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.328 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.329 :param auth: (optional) AuthObject to enable Basic HTTP Auth.330 """331 332 r = Request()333334 r.url = url335 r.method = 'DELETE'
39 unmodified lines