[Twisted-web] internal vs. external hostname in Request.getHost9)

Ilya Skriblovsky ilyaskriblovsky at gmail.com
Tue Mar 14 00:01:00 MDT 2017


Hi,

I'm using Twisted Web server behind Nginx reverse-proxy and I'm getting
backend's internal host:port from Request.getHost().

Seems like Request.host is explicitly set to socket's address (i.e.
internal address) here: ​
https://github.com/twisted/twisted/blob/trunk/src/twisted/web/http.py#L838
But comment at ​
https://github.com/twisted/twisted/blob/trunk/src/twisted/web/http.py#L1297
and what this method does points that Request.host meant to reflect Host
header of the request, i.e. user-visible hostname and port.

This creates problems for me when using Klein because it correctly uses
Request.getHost() to create host part of URLs for redirects.

It seems like inconsistency in Twisted code. I'd expect Request.host should
be only set from the Host request header to reflect user-visible hostname,
not the internal backend server's address. Or may be I'm missing something?

Thanks for reply

--
  ilya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-web/attachments/20170314/e92cbc15/attachment.html>


More information about the Twisted-web mailing list