Skip to content
Myr

filling out the gaps

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

  • other:+49 added−14 removed

1 file+49 added−14 removed

modified:requests/core.py+49 added-14 removed
48 unmodified lines
49 raise InvalidMethod()50 51 object.__setattr__(self, name, value)52 53 53 54 def _checks(self):55 pass56 57 def send(self, anyway=False):58 """Sends the request. 59 60 :param anyway: If True, request will be sent, even if it has already been sent.61 """62 self._checks()63 64 if self.method.lower() == 'get':65 if (not self.sent) or anyway:66 try: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()67 r = urllib.urlopen('http://kennethreitz.com')68 self.response.headers = r.headers.dict69 self.response.status_code = r.code70 self.response.content = r.read()71 72 success = True7374 except Exception:75 raise RequestException76 77 67 success = True68 78 elif self.method.lower() == 'head':79 if (not self.sent) or anyway:80 try:71 pass81 pass82 83 success = True8485 except Exception:86 raise RequestException87 88 elif self.method.lower() == 'put':89 if (not self.sent) or anyway:90 try:75 pass91 pass92 93 success = True9495 except Exception:96 raise RequestException97 98 elif self.method.lower() == 'post':99 if (not self.sent) or anyway:100 try:79 pass101 pass102 103 success = True104105 except Exception:106 raise RequestException107108 elif self.method.lower() == 'delete':109 if (not self.sent) or anyway:110 try:83 pass111 pass112 113 success = True114115 except Exception:116 raise RequestException117 85 #set self.response118 else:119 raise InvalidMethod12087 if success:88 self.sent = True121 122 self.sent = True if success else False123 124 return success125 126127class Response(object):
131 unmodified lines