Created
June 14, 2010 14:29
-
-
Save anonymous/437751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://gtap.googlecode.com/svn/branches/oauth-dev | |
Index: main.py | |
=================================================================== | |
--- main.py (リビジョン 37) | |
+++ main.py (作業コピー) | |
@@ -29,12 +29,13 @@ | |
headers = {} | |
else: | |
auth_header = self.request.headers['Authorization'] | |
- auth_parts = auth_header.split(' ') | |
- user_pass_parts = base64.b64decode(auth_parts[1]).split(':') | |
- username = user_pass_parts[0] | |
- password = user_pass_parts[1] | |
- base64string = base64.encodestring('%s:%s' % (username, password))[:-1] | |
- headers = {'Authorization': "Basic %s" % base64string} | |
+ #auth_parts = auth_header.split(' ') | |
+ #user_pass_parts = base64.b64decode(auth_parts[1]).split(':') | |
+ #username = user_pass_parts[0] | |
+ #password = user_pass_parts[1] | |
+ #base64string = base64.encodestring('%s:%s' % (username, password))[:-1] | |
+ #headers = {'Authorization': "Basic %s" % base64string} | |
+ headers = {'Authorization': self.request.headers['Authorization']} | |
path_parts = path.split('/') | |
@@ -54,7 +55,7 @@ | |
gtap_message = gtap_message.replace('#gtap_version#', gtap_vrsion) | |
self.my_output( 'text/html', gtap_message ) | |
else: | |
- new_url = urlparse.urlunparse(('https', new_netloc, new_path.replace('//','/'), params, query, '')) | |
+ new_url = urlparse.urlunparse((scm, new_netloc, new_path.replace('//','/'), params, query, '')) | |
logging.debug(new_url) | |
data = urlfetch.fetch(new_url, payload=orig_body, method=method, headers=headers, allow_truncated=True) | |
@@ -67,6 +68,14 @@ | |
self.response.headers.add_header('GTAP-Version', gtap_vrsion) | |
for res_name, res_value in data.headers.items(): | |
if is_hop_by_hop(res_name) is False and res_name!='status': | |
+ res_name = res_name \ | |
+ .replace('x-transaction', 'X-Transaction') \ | |
+ .replace('x-ratelimit-limit', 'X-RateLimit-Limit') \ | |
+ .replace('x-ratelimit-remaining', 'X-RateLimit-Remaining') \ | |
+ .replace('x-runtime', 'X-Runtime') \ | |
+ .replace('x-ratelimit-class', 'X-RateLimit-Class') \ | |
+ .replace('x-revision', 'X-Revision') \ | |
+ .replace('x-ratelimit-reset', 'X-RateLimit-Reset') | |
self.response.headers.add_header(res_name, res_value) | |
self.response.out.write(data.content) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment