cuongphphanoi / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

bug+patch: CGI failure on Windows when CGI interpreter is on a different drive #364

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. get the ajax/echo.cgi from the bel2125 clone or create a very simple 
hello-world CGI using your interpreter of choice - here it's lua.exe

2. place mongoose server AND test website on a different drive, say D:, then 
point mongoose at this document_root using a RELATIVE PATH, while the CGI 
interpreter is at drive C:, e.g.
  mongoose -r ./test/ -I c:/lua/lua.exe

3. browse to http://localhost:8080/ajax/echo.cgi or your own hello-world cgi 
script as described in step 1.

What is the expected output? What do you see instead?

Expected: CGI script runs and outputs some text.
Observed: 5xx HTTP response code because CGI interpreter cannot find the 
script, since it's given this commandline - assuming the example above:
  c:/lua/lua.exe ./test/ajax/echo.cgi
which will NOT work as the interpreter is NOT aware that the script resides on 
a DIFFERENT DRIVE -- so the relative path won't work.

What version of the product are you using? On what operating system?

bleeding edge mongoose
Win7/64
LUA 5.1.4

Please provide any additional information below.

patch included. The solution is to have mongoose transform all URIs to ABSOLUTE 
paths on Windows at least (I'm still of two minds whether this should also be 
done in UNIX; one might argue that this relative path problem won't happen 
there as everything is based off a single root node '/', so this whole 'drive' 
surprise won't happen in a UNIXy environment.

This is NOT fixed in the CGI handler itself but rather in the convert uri to 
path common call as others than CGI may also suffer from this, e.g. when people 
implement their own CGI-like stuff in the MG_NEW_REQUEST event callback. Hence 
mongoose should feed the event callback an absolute filesystem path for the 
given URI as well, which is what placing the patch in the common convert uri to 
path call accomplishes.

Original issue reported on code.google.com by ger.hobbelt on 13 Jun 2012 at 10:50

GoogleCodeExporter commented 8 years ago
patch extracted from git ( https://github.com/GerHobbelt/mongoose , 
https://github.com/GerHobbelt/mongoose/commit/99008f5c721e264f202410a7f1039b8cc1
88c5b6 )

Original comment by ger.hobbelt on 13 Jun 2012 at 10:56

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by valenok on 22 Sep 2012 at 2:10