#139 new
Chris Davaz


Reported by Chris Davaz | October 26th, 2010 @ 03:35 PM

I am using Sinatra with thin and I found that accessing request.env[REQUEST_URI] only gave me the base portion of the uri with no SCRIPT_NAME or PATH_INFO. Those latter two variables were also empty. Using other web services with Sinatra shows the correct values of REQUEST_URI, SCRIPT_NAME and PATH_INFO.

Comments and changes to this ticket

  • macournoyer

    macournoyer October 27th, 2010 @ 03:18 PM

    Hey Chris, could you paste the full inspect of the request.env.

  • Chris Davaz

    Chris Davaz October 27th, 2010 @ 05:10 PM

    Actually I see that REQUEST_URI is set correctly, I was mistaking it with request.url which was not being set correctly. In the output SCRIPT_NAME and PATH_INFO are empty.

    {"HTTP_HOST"=>"", "HTTP_ACCEPT"=>"application/json", "SERVER_NAME"=>"", "rack.url_scheme"=>"http", "CONTENT_LENGTH"=>"1169", "SERVER_PROTOCOL"=>"HTTP/1.1", "CONTENT_TYPE"=>"application/json", "rack.errors"=>#<Rack::Lint::ErrorWrapper:0x7f4652584b30 @error=#<IO:0x7f4658eadaa8>>, "async.callback"=>#<Method: Thin::Connection#post_process>, "REMOTE_ADDR"=>"", "PATH_INFO"=>"", "rack.run_once"=>false, "rack.version"=>[1, 0], "SERVER_SOFTWARE"=>"thin 1.2.7 codename No Hup", "SCRIPT_NAME"=>"", "HTTP_AUTHORIZATION"=>"CDEF dGVzdGVyOjVmMzg4MTdmYTVjNjIxZDRkMzUzNmU5MjhiODgzYTliNDI1NGYyM2VmNDU0OTU3NGQwOTg2ZjAxMjdjMTUyZTI=", "HTTP_VERSION"=>"HTTP/1.1", "rack.multithread"=>false, "REQUEST_URI"=>"", "rack.multiprocess"=>false, "rack.request.query_hash"=>{}, "SERVER_PORT"=>"9292", "async.close"=>#<EventMachine::DefaultDeferrable:0x7f4652598ae0>, "REQUEST_METHOD"=>"POST", "HTTP_DATE"=>"Wed, 27 Oct 2010 20:03:19 GMT", "rack.request.query_string"=>"", "QUERY_STRING"=>"", "GATEWAY_INTERFACE"=>"CGI/1.2", "rack.input"=>#<Rack::Lint::InputWrapper:0x7f4652584bf8 @input=#<StringIO:0x7f46525b9fd8>>}

  • macournoyer

    macournoyer November 4th, 2010 @ 03:28 PM

    I'm confused now. Is it still an issue?

  • Chris Davaz

    Chris Davaz November 4th, 2010 @ 04:37 PM

    Yes, it is still an issue because SCRIPT_NAME and PATH_INFO are empty. From the rack spec:

    SCRIPT_NAME: The initial portion of the request URL’s “path” that corresponds to the application object, so that the application knows its virtual “location”. This may be an empty string, if the application corresponds to the “root” of the server.
    PATH_INFO: The remainder of the request URL’s “path”, designating the virtual “location” of the request’s target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when I originating from a URL.

    Not setting them causes a problem since I use request.path to put together a message signature. Of course I could parse this information myself from REQUEST_URI but that would be a workaround put in place just to use thin.

  • macournoyer

    macournoyer November 4th, 2010 @ 04:55 PM

    I think I see the issue now. You're doing a request w/ an absolute URL, only relative URLs are supported atm. I know it's in the specs, but all browsers use relative URLs.

    How are you sending that request?

  • Chris Davaz

    Chris Davaz November 4th, 2010 @ 05:52 PM

    I'm writing a REST-style API where requests are sent from a command (such as Curl). Actually in my specific case I'm making the request from another Ruby script using net/http.

    I'm not familiar with the Rack or Thin codebase so maybe this is naive, but, I think all that would need to be done is parse out the values for SCRIPT_NAME and PATH_INFO from REQUEST_URI and set them in the env[] before thin passes on the request object.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket