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

Unified Diff: multiplexer.fcgi

Issue 5747446760079360: Issue 402 - Use a redirector script for downloads, not a direct link (Closed)
Patch Set: Created Sept. 15, 2014, 11:39 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 | multiplexer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: multiplexer.fcgi
===================================================================
--- a/multiplexer.fcgi
+++ b/multiplexer.fcgi
@@ -24,16 +24,20 @@ from sitescripts.web import handlers
class MultiplexerApp:
def __call__(self, environ, start_response):
if 'REQUEST_URI' in environ:
request = urlparse(environ['REQUEST_URI'])
if request.path in handlers:
return handlers[request.path](environ, start_response)
+ request_dir = re.sub(r'[^/]+$', '', request.path)
+ if request_dir in handlers:
+ return handlers[request_dir](environ, start_response)
+
start_response('404 Not Found', [('Content-Type', 'text/html')])
return ["Not Found"]
bindAddress = None
if 'FCGI_BIND_ADDRESS' in os.environ:
match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS'])
bindAddress = (match.group(1), int(match.group(2)))
srv = WSGIServer(MultiplexerApp(), debug=False, bindAddress=bindAddress)
« no previous file with comments | « no previous file | multiplexer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld