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) |