On 16/12/05 00:02 Richard Wall wrote:
> Infact, in my case anyway, the only problem running behind a proxy is
> that twisted.web refers to it's listening port instead of reading it
> from the http headers. Looking at twisted.web.server the following
> change fixes the port problem for me...
Maybe that last patch was a bit daft. I've attached a better version.
Hope someone will consider applying it.
--
Richard Wall
Index: /home/richard/lib/Twisted/trunk/twisted/web/server.py
===================================================================
--- /home/richard/lib/Twisted/trunk/twisted/web/server.py (revision 15343)
+++ /home/richard/lib/Twisted/trunk/twisted/web/server.py (working copy)
@@ -342,11 +342,23 @@
return self.session
def _prePathURL(self, prepath):
- port = self.getHost().port
if self.isSecure():
default = 443
else:
default = 80
+
+ # There won't always be a hostheader, but if it's present, try and find
+ # the port number from it.
+ hostheader = self.getHeader('host')
+ if hostheader:
+ hostheader = hostheader.split(":", 1)
+ if len(hostheader) == 2:
+ port = int(hostheader[1])
+ else:
+ port = default
+ else:
+ port = self.getHost().port
+
if port == default:
hostport = ''
else:
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web