| Index: modules/rietveld/files/wrapper.py |
| diff --git a/modules/rietveld/files/wrapper.py b/modules/rietveld/files/wrapper.py |
| index 34ed099a19360cef1cb0bebdc184d0fd77ce1468..e714122c0b49e4566724c289cc4496bd37f5fc15 100644 |
| --- a/modules/rietveld/files/wrapper.py |
| +++ b/modules/rietveld/files/wrapper.py |
| @@ -203,6 +203,28 @@ def enable_oauth2(client_id, client_secret, admins): |
| user_service_stub.UserServiceStub._Dynamic_GetOAuthUser = _Dynamic_GetOAuthUser |
| +def dispatch_tasks_to_user_port(): |
| + """ |
| + 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 dispatch_tasks_to_user_port() 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 will fail, because applications will omit the |
| + default port when addressing resources. |
| + """ |
| + from google.appengine.tools.devappserver2.dispatcher import Dispatcher |
| + from google.appengine.api import request_info |
| + |
| + resolve_target = Dispatcher._resolve_target |
| + |
| + def callback(dispatcher, authority, path): |
| + hostname, port = authority.split(":") if ":" in authority else (authority, dispatcher._port) |
| + new_authority = "%s:%d" % (hostname, port) |
| + result = resolve_target(dispatcher, new_authority, path) |
| + return result |
| + |
| + Dispatcher._resolve_target = callback |
| if __name__ == '__main__': |
| engine_dir = '/opt/google_appengine' |
| @@ -223,5 +245,6 @@ if __name__ == '__main__': |
| config.get('oauth2', 'client_secret'), |
| config.get('main', 'admins').split() |
| ) |
| + dispatch_tasks_to_user_port() |
| execfile(script_file) |