Annotate tools/run-dev.py.

This commit is contained in:
Tim Abbott 2016-07-29 15:51:14 -07:00
parent cc11229377
commit 89267f926e
1 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,8 @@ import traceback
import sys import sys
import os import os
if False: from typing import Any
# find out python version # find out python version
major_version = int(subprocess.check_output(['python', '-c', 'import sys; print(sys.version_info[0])'])) major_version = int(subprocess.check_output(['python', '-c', 'import sys; print(sys.version_info[0])']))
if major_version != 2: if major_version != 2:
@ -27,6 +29,7 @@ from twisted.web import proxy, server, resource
from twisted.web.http import Request from twisted.web.http import Request
orig_finish = Request.finish orig_finish = Request.finish
def patched_finish(self): def patched_finish(self):
# type: (Any) -> None
if not self._disconnected: if not self._disconnected:
orig_finish(self) orig_finish(self)
Request.finish = patched_finish Request.finish = patched_finish
@ -115,6 +118,8 @@ for cmd in cmds:
class Resource(resource.Resource): class Resource(resource.Resource):
def getChild(self, name, request): def getChild(self, name, request):
# type: (str, server.Request) -> resource.Resource
# Assume an HTTP 1.1 request # Assume an HTTP 1.1 request
proxy_host = request.requestHeaders.getRawHeaders('Host') proxy_host = request.requestHeaders.getRawHeaders('Host')
request.requestHeaders.setRawHeaders('X-Forwarded-Host', proxy_host) request.requestHeaders.setRawHeaders('X-Forwarded-Host', proxy_host)