Changes between Version 2 and Version 3 of Ticket #1928, comment 10


Ignore:
Timestamp:
2016-01-31T14:38:49Z (9 years ago)
Author:
leif
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1928, comment 10

    v2 v3  
    1313
    1414* Various objects in Tahoe (in places like [https://github.com/tahoe-lafs/tahoe-lafs/blob/master/src/allmydata/web/directory.py#L578 directory.py]) subclass Nevow's `rend.Page` and use its `addSlash` feature.
    15 * Nevow's [https://github.com/twisted/nevow/blob/397f5f789753a919c6f21b58a487db1b9fe8567a/nevow/rend.py#L540 rend.Page] then calls `request.URLPath()` which I believe is from [https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/twisted/web/server.py#L434 twisted.web.server.Request.URLPath], which calls [https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/twisted/python/urlpath.py#L174 twisted.python.urlpath.URLPath.fromRequest] which calls back to [https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/twisted/web/server.py#L430 twisted.web.server.Request.prePathURL] which calls `_prePathURL` which finally calls [https://twistedmatrix.com/documents/current/api/twisted.web.http.Request.html#getHost twisted.web.http.Request.getHost] which returns a [https://twistedmatrix.com/documents/current/api/twisted.internet.tcp.Port.html twisted.internet.tcp.Port] from which it (`Request.getHost`) brazenly accesses the apparently-undocumented instance attribute `port` and stuffs it in a URL.
     15* Nevow's [https://github.com/twisted/nevow/blob/397f5f789753a919c6f21b58a487db1b9fe8567a/nevow/rend.py#L540 rend.Page] then calls `request.URLPath()` which I believe is from [https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/twisted/web/server.py#L434 twisted.web.server.Request.URLPath], which calls [https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/twisted/python/urlpath.py#L174 twisted.python.urlpath.URLPath.fromRequest] which calls back to [https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/twisted/web/server.py#L430 twisted.web.server.Request.prePathURL] which calls `_prePathURL` which finally calls [https://twistedmatrix.com/documents/current/api/twisted.web.http.Request.html#getHost twisted.web.http.Request.getHost] which returns a [https://twistedmatrix.com/documents/current/api/twisted.internet.tcp.Port.html twisted.internet.tcp.Port] from which it (`Request.getHost`) brazenly accesses the apparently-undocumented instance attribute `port` and stuffs it in a URL. (Or so it seems.)
    1616 * I was going to say this seems problematic as it would prevent Twisted's webserver from being run on other transports, like a UNIX Socket. So I created an example of that with `mkdir -p foo/bar; twistd -n web -p unix://tmp/unixweb  --path foo` and a made a TCP-to-unix proxy with `socat TCP4-LISTEN:8080,fork,reuseaddr unix://tmp/unixweb` and then sent a request with `curl -v http://127.0.0.1:8080/bar` ... but much to my surprise I got a response with `Location: http://127.0.0.1:8080/bar/`! So then I tested with Tahoe using my original instructions in this ticket description and found that the correct port number is now there as well. From reading the code I linked to above I'm not actually sure how this is happening, but it is.
    1717  * I did find a case where a Twisted webserver listening on a UNIX socket produces bad redirects, though: When there are `HTTP/1.0` requests (meaning, without a `Host` header), the `Location` header in the response begins with `http://None/`).