Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

PATH_INFO trailing slashes are stripped #81

Closed
cpjolicoeur opened this issue Apr 11, 2011 · 17 comments
Closed

PATH_INFO trailing slashes are stripped #81

cpjolicoeur opened this issue Apr 11, 2011 · 17 comments
Labels

Comments

@cpjolicoeur
Copy link

pow doesnt seem to be setting the REQUEST_URI request.env variable for rails apps.

thin sets this request.env var, but running the app under pow does not

@tinderfields
Copy link

I have this same problem.

@josh
Copy link
Contributor

josh commented Apr 12, 2011

REQUEST_URI is not part of the Rack spec. It was considered but rejected since most web servers get it wrong and its just duplicate information. See env['PATH_INFO'].

@josh josh closed this as completed Apr 12, 2011
@cpjolicoeur
Copy link
Author

env['PATH_INFO'] does not give the same output as env['REQUEST_URI']

For instance, in my specific use case, my url may be http://example.com/foo/bar/ (with a trailing slash).

env["REQUEST_URI'] == '/foo/bar/' (with trailing slash)

while

env['PATH_INFO'] == '/foo/bar' (no trailing slash)

Any idea how to get the actual full URL value from env including the trailing slash if REQUEST_URI is not universally supported?

  • Craig
    On Tuesday, April 12, 2011 at 11:33 AM, josh wrote:

    REQUEST_URI is not part of the Rack spec. It was considered but rejected since most web servers get it wrong and its just duplicate information. See env['PATH_INFO'].

    --
    Reply to this email directly or view it on GitHub:
    PATH_INFO trailing slashes are stripped #81 (comment)

@josh
Copy link
Contributor

josh commented Apr 12, 2011

Made my point, REQUEST_URI is inconsistent everywhere.

SCRIPT_NAME + PATH_INFO is always right.

Also see: https://github.com/rack/rack/blob/master/lib/rack/request.rb#L271

@cpjolicoeur
Copy link
Author

I'm not arguing the inconsistency of REQUEST_URI, I agree with you.

Just curious as to how to get the true path of the URL.

PATH_INFO, #fullpath, and #path all strip off the trailing slash.

So it appears there is no possible way (via env or otherwise) to get the fullpath including trailing slash from rack?

see attached debug screenshot as well: http://cl.ly/2o1d3B2t1K3Y3d1k1e0p

@josh
Copy link
Contributor

josh commented Apr 12, 2011

Hrm, maybe this a issue with nodejs. I'm just using whatever it gives me as the path. PATH_INFO should be /real-estate/investments/ in that case.

@cpjolicoeur
Copy link
Author

ok, thx. I'll take this over to node.js and file a ticket there

@josh
Copy link
Contributor

josh commented Apr 12, 2011

@josh
Copy link
Contributor

josh commented Apr 12, 2011

This looks correct though:

> url.parse("http://example.org/foo/")
{ protocol: 'http:',
  slashes: true,
  host: 'example.org',
  hostname: 'example.org',
  pathname: '/foo/',
  href: 'http://example.org/foo/' }

@josh josh reopened this Apr 12, 2011
@josh
Copy link
Contributor

josh commented Apr 12, 2011

We should figure out where this is actually happening.

@cpjolicoeur
Copy link
Author

So, I'm not sure I follow to this point.

Do you think its a node.js issue that I should file a ticket there or is this related to the nack source?

@cpjolicoeur
Copy link
Author

I'll be more than happy to help out as I can since I filed the ticket, but my node experience to date is very minimal (read nearly non-existent) so I'm not sure where to even begin.

@josh
Copy link
Contributor

josh commented Apr 12, 2011

I wouldn't file a ticket until we are sure thats the issue.

@josh
Copy link
Contributor

josh commented Apr 12, 2011

Node's server seems to be correct:

var http = require('http');
var url  = require('url');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end(JSON.stringify(url.parse(req.url)));
}).listen(8124, "127.0.0.1");

$ curl http://127.0.0.1:8124/foo/
{"pathname":"/foo/","href":"/foo/"}

@cpjolicoeur
Copy link
Author

I tested this while running on the thin server as well and get the same output that I am getting from Pow/Nack

So, is it the case that PATH_INFO is not very well standardized as well, just like REQUEST_URI

  • Craig
    On Tuesday, April 12, 2011 at 12:04 PM, josh wrote:

    Node's server seems to be correct:

    var http = require('http');
    var url = require('url');
    http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(JSON.stringify(url.parse(req.url)));
    }).listen(8124, "127.0.0.1");

    $ curl http://127.0.0.1:8124/foo/
    {"pathname":"/foo/","href":"/foo/"}

    --
    Reply to this email directly or view it on GitHub:
    PATH_INFO trailing slashes are stripped #81 (comment)

@josh
Copy link
Contributor

josh commented Apr 12, 2011

I actually can't reproduce here.

Can you try starting an example rails app. It could be some stuff in your stack mutating the env.

@cpjolicoeur
Copy link
Author

Ok,

I'll try to reproduce at the barest level as possible on my end.

Just to clarify, you are running via Pow and a url in the format /foo/bar/ is returning the correct "/foo/bar/" string for PATH_INFO, correct?

  • Craig
    On Tuesday, April 12, 2011 at 12:09 PM, josh wrote:

    I actually can't reproduce here.

    Can you try starting an example rails app. It could be some stuff in your stack mutating the env.

    --
    Reply to this email directly or view it on GitHub:
    PATH_INFO trailing slashes are stripped #81 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants