Permalink
Browse files

bug fix: oauth_http_request support GET method

  • Loading branch information...
1 parent 45e57f6 commit e38d09a9e09d4b8d2a0ea645635c3fdb22bd41ce @techno techno committed Jul 4, 2010
Showing with 10 additions and 6 deletions.
  1. +10 −6 twoauth/oauth.py
View
@@ -164,7 +164,7 @@ def oauth_request(self, url, method = "GET", add_params = {}):
return req
# Return httplib.HTTPResponse (for DELETE Method and Streaming API
- def oauth_http_request(self, url, method = "GET", add_params = {}):
+ def oauth_http_request(self, url, method = "GET", add_params = {}, header = {}):
enc_params = {}
if add_params:
api_params = urllib.urlencode(add_params)
@@ -173,14 +173,18 @@ def oauth_http_request(self, url, method = "GET", add_params = {}):
else:
api_params = ""
+ header["Authorization"] = self.oauth_header(url, method, enc_params, self.asecret)
+
urlp = urlparse.urlparse(url)
- con = httplib.HTTPConnection(urlp.netloc)
+ conn = httplib.HTTPConnection(urlp.netloc)
- con.request(method, urlp.path, api_params, {
- "Authorization" :
- self.oauth_header(url, method, enc_params, self.asecret)})
+ if method == "GET":
+ path = "%s?%s" % (urlp.path, api_params)
+ conn.request(method, path, headers = header)
+ else:
+ conn.request(method, urlp.path, api_params, header)
- return con
+ return conn
# Get random string (for oauth_nonce)
def _rand_str(self, n):

0 comments on commit e38d09a

Please sign in to comment.