fixes
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 ef9bae8 · Browse files · 1 file·+53 added−13 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+53 added−13 removed
- other:+53 added−13 removed
Provenance
- Commit
32cc197- Tree
d567f2a- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
ef9bae8
1 file changed+53 added−13 removed
modified:requests/core.py+53 added-13 removed
11 unmodified lines12 13 import httplib14 import urllib15 import urllib216+import urlparse17 17-import requests.handler18 19 __title__ = 'requests'20 __version__ = '0.0.1'21 __build__ = 0x0000011 unmodified line23 __license__ = 'ISC'24 __copyright__ = 'Copyright 2011 Kenneth Reitz'25 26 27-AUTHOAUTHS = []27+AUTOAUTHS = []28 29 30 class Request(object):31 """The :class:`Request` object. It's awesome.3 unmodified lines35 36 def __init__(self):37 self.headers = dict()38 self.method = None39- self.response = None39+ self.response = Response()40 self.auth = None41+ 42 42- def __setattr__(self, key, val):43- if key == 'method':44- if not val.lower() in _METHODS:43+ def __setattr__(self, name, value):44+ if (name == 'method') and (value):45+ if not value.lower() in self._METHODS:46 raise InvalidMethod()47 48+ object.__setattr__(self, name, value)49+ 50+ 51 def send(self):52 """Sends the request. """53 #set self.response54+55 # return True / False56 57 58 class Response(object):23 unmodified lines82 """Sends a GET request. Returns :class:`Response` object.83 """84 r = Request()85 86+ r.method = 'GET'87 r.url = url88 r.headers = headers89 r.auth = _detect_auth(url, auth)84- r.method = 'GET'90+ 91 r.send()92 93 return r.response88- 89- # return response object94 95 96 def head(url, params={}, headers={}, auth=None):97 """Sends a HEAD request. Returns :class:`Response` object.98 """95- pass99+ r = Request()100+ 101+ r.method = 'HEAD'102 # return response object103+ 104+ r.headers = headers105+ r.auth = _detect_auth(url, auth)106+ 107+ r.send()108+ 109+ return r.response110 111 112 def post(url, params={}, headers={}, auth=None):113 """Sends a POST request. Returns :class:`Response` object.114 """102- pass115+ r = Request()116+ 117+ r.method = 'POST'118 # return response object119 120+ r.headers = headers121+ r.auth = _detect_auth(url, auth)122 123+ r.send()124+ 125+ return r.response126+ 127+ 128 def put(url, data='', headers={}, auth=None):129 """Sends a PUT request. Returns :class:`Response` object.130 """109- pass131+ r = Request()132+ 133+ r.method = 'PUT'134 # return response object135+ 136+ r.headers = headers137+ r.auth = _detect_auth(url, auth)138+ 139+ r.send()140+ 141+ return r.response142 143 144 def delete(url, params={}, headers={}, auth=None):145 """Sends a DELETE request. Returns :class:`Response` object.146 """116- pass147+ r = Request()148+ 149+ r.method = 'DELETE'150 # return response object151+ 152+ r.headers = headers153+ r.auth = _detect_auth(url, auth)154+ 155+ r.send()156+ 157+ return r.response158 159 160 def add_autoauth(url, authobject):161 global AUTOAUTHS28 unmodified lines