SCRIPT_NAME and PATH_INFO

541 views
Skip to first unread message

Tor...@robitzki.de

unread,
Jul 12, 2012, 11:01:27 AM7/12/12
to rack-...@googlegroups.com
Hello,
I'm currently writing a server handler for a C++ comet server and I'm unsure how to divide a url path into these both variables. Does the sum of both have to be path part of the url (according to rfc3986)? If so, can I choose the SCRIPT_NAME freely and than just fill PATH_INFO with the remaining part and add a '/' if that remaining part is empty? Example:

path: '/'
=> env['SCRIPT_NAME'] = '/'; env['PATH_INFO'] = '/'

path: '/a/b'
=> env['SCRIPT_NAME'] = '/'; env['PATH_INFO'] = '/a/b'
or => env['SCRIPT_NAME'] = '/a'; env['PATH_INFO'] = '/b'
or => env['SCRIPT_NAME'] = '/a/b'; env['PATH_INFO'] = '/'

is this right?

best regards
Torsten

--
Torrox GmbH & Co. KG
persönlich haftender Gesellschafter: Torrox Verwaltungs GmbH, Hannover (Amtsgericht Hannover, HRB 207530)
Geschäftsleitung: Dipl.-Ing. Torsten Robitzki
Adresse: Stolzestr. 26; 30171 Hannover
Handelsregistereintrag: Amtsgericht Hannover, HRA 202170
Telefon: +49 511 31018758






Konstantin Haase

unread,
Jul 18, 2012, 12:48:41 PM7/18/12
to rack-...@googlegroups.com
SCRIPT_NAME is used to mount an app nested somewhere.

If you run for instance a normal Rails or Sinatra app on http://localhost:5000/, then should SCRIPT_NAME == "" and PATH_INFO = "/".

Now if you want to run your Rails app from /foo instead of /, the /foo will be removed from PATH_INFO and added to SCRIPT_NAME.

This is used by so called Rack routers, for instance the `map` method you have in the Rack DSL.

Konstantin
Reply all
Reply to author
Forward
0 new messages