Skip to content
Myr

GET and POST completely in place

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 44aa680 · Browse files · 1 file+33 added−1 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+33 added−1 removed

  • other:+33 added−1 removed

1 file+33 added−1 removed

modified:requests/core.py+33 added-1 removed
63 unmodified lines
64 65 if self.method.lower() == 'get':66 if (not self.sent) or anyway:67 try:68 pass68 req = urllib2.Request(self.url)6970 if self.headers:71 r.headers = self.headers7273 # url encode form data if it's a dict74 if isinstance(self.data, dict):75 req.params = urllib.urlencode(self.params)76 else:77 req.params = self.paams7879 if self.auth:8081 # create a password manager82 password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()8384 # Add the username and password.85 # If we knew the realm, we could use it instead of ``None``.86 password_mgr.add_password(None, self.url, self.auth.username, self.auth.password)87 handler = urllib2.HTTPBasicAuthHandler(password_mgr)88 opener = urllib2.build_opener(handler)8990 # use the opener to fetch a URL91 resp = opener.open(req)92 else:93 resp = urllib2.urlopen(req)9495 self.response.status_code = resp.code96 self.response.headers = resp.info().dict97 self.response.content = resp.read()9899 success = True100101102 except Exception:103 raise RequestException104 105
212 unmodified lines