Skip to content
Myr

Base GET in place. No AUTH yet.

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 49f915f · Browse files · 1 file+37 added−3 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+37 added−3 removed

  • other:+37 added−3 removed

1 file+37 added−3 removed

modified:requests/core.py+37 added-3 removed
34 unmodified lines
35 36 def __init__(self):37 self.headers = dict()38 self.method = None39 self.params = {}40 self.data = None41 self.response = Response()42 self.auth = None43 self.sent = False44 45 46 def __setattr__(self, name, value):47 if (name == 'method') and (value):
2 unmodified lines
50 51 object.__setattr__(self, name, value)52 53 51 def send(self):52 """Sends the request. """54 def send(self, anyway=False):55 """Sends the request. 56 57 :param anyway: If True, request will be sent, even if it has already been sent.58 """59 60 if self.method.lower() == 'get':61 if (not self.sent) or anyway:62 r = urllib.urlopen('http://kennethreitz.com')63 self.response.headers = r.headers.dict64 self.response.status_code = r.code65 self.response.content = r.read()66 67 success = True68 69 elif self.method.lower() == 'head':70 if (not self.sent) or anyway:71 pass72 73 elif self.method.lower() == 'put':74 if (not self.sent) or anyway:75 pass76 77 elif self.method.lower() == 'post':78 if (not self.sent) or anyway:79 pass8081 elif self.method.lower() == 'delete':82 if (not self.sent) or anyway:83 pass84 85 #set self.response8655 # return True / False87 if success:88 self.sent = True89 return success90 9192class Response(object):93 """The :class:`Request` object. It's awesome.
130 unmodified lines