Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/rietveld/files/wrapper.py

Issue 29321013: Issue 2682 - Fix GAE dispatcher default port handling (Closed)
Patch Set: Issue 2682 - Fix GAE dispatcher default port handling Created June 23, 2015, 10:12 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/rietveld/files/wrapper.py
diff --git a/modules/rietveld/files/wrapper.py b/modules/rietveld/files/wrapper.py
index 34ed099a19360cef1cb0bebdc184d0fd77ce1468..4d174f613149f3fdd0ff58e7184dda55372fde9a 100644
--- a/modules/rietveld/files/wrapper.py
+++ b/modules/rietveld/files/wrapper.py
@@ -203,6 +203,25 @@ def enable_oauth2(client_id, client_secret, admins):
user_service_stub.UserServiceStub._Dynamic_GetOAuthUser = _Dynamic_GetOAuthUser
+def fix_target_resolution():
+ """
+ By default, the dispatcher assumes port 80 for target authorities that
+ only contain a hostname but no port part. This hard-coded behavior is
+ altered in function fix_target_resolution() so that the port given
+ as --port option to the appserver-script is used instead. Without this
+ monkey-patch, dispatching tasks from an application run behind a HTTP
+ proxy server on port 80 (or HTTPS on 443) will fail, because
+ applications will omit the default port when addressing resources.
+ """
+ from google.appengine.tools.devappserver2.dispatcher import Dispatcher
+ orig_resolve_target = Dispatcher._resolve_target
+
+ def resolve_target(dispatcher, hostname, path):
+ new_hostname = hostname if ":" in hostname else "%s:%d" % (hostname, dispatcher._port)
+ result = orig_resolve_target(dispatcher, new_hostname, path)
+ return result
+
+ Dispatcher._resolve_target = resolve_target
if __name__ == '__main__':
engine_dir = '/opt/google_appengine'
@@ -223,5 +242,6 @@ if __name__ == '__main__':
config.get('oauth2', 'client_secret'),
config.get('main', 'admins').split()
)
+ fix_target_resolution()
execfile(script_file)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld