В Thu, 23 Dec 2010 08:03:46 +0100
Nicolas Cannasse <[email protected]> пишет:

> Le 22/12/2010 21:36, Alexander Konotop a écrit :
> > TO Nicolas Canasse: Ok, I'll rewrite Web.hx and share it. But at
> > first I'd like to ask You: why does nekotools-server work well?
> > Doesn't it execute neko in CGI mode?
> 
> No it doesn't, it instead emulate mod_neko directly, which enable it
> to work exactly the same as Apache+mod_neko
> 
> Nicolas
> 

We made it working in CGI mode! Tested with lighttpd and with IIS.
Changed line 348 in neko/Web.hx from:
----------
var a0 = untyped __dollar__loader.args[0];
----------
to:
----------
var a0 = Sys.getEnv("QUERY_STRING");
----------
and that's all!

I thought "what if different webservers send different headers to cgi
application?" and tested it with IIS and got strange results.

At first I didn't see that lighty sends the QUERY_STRING variable. But
I've seen that it sends REQUEST_URI=>/nekocgi/gettest/gettest.n?a=3&b=3.
Then I wrote the test code:
----------
var tempstring : String = Sys.getEnv("REQUEST_URI");
var temparray : Array<String> = tempstring.split("?");
var a0 = temparray[1];
----------
instead of
----------
var a0 = untyped __dollar__loader.args[0];
----------

It has worked in lighty but has thrown an error in IIS.

Then by chance I noticed a "QUERY_STRING" variable that lighttpd sends
to neko. I tried it and it worked both in IIS and lighttpd! I think it
will work in nginx and other servers, too.

It seems like IIS doesn't generate the "REQUEST_URI" variable but
generates "QUERY_STRING" like lighttpd does.

That's why we couldn't see it before:

We couldn't make this line
----------
trace(neko.Web.getParamsString());
----------
work in IIS. It simply prints nothing. And even more! IIS throws error
in CGI mode if we don't print at the start of our output this:
----------
 neko.Lib.print("Status: 200 OK");
 neko.Lib.print("\n");
 neko.Lib.print("Content-type: text/html");
 neko.Lib.print("\n");
 neko.Lib.print("\n");
----------
And yes, it's mandatory to print ("\n") twice between these headers and
our output.

This information we found here:
http://support.microsoft.com/kb/276494
(seems like python developers have the same problem :))

Lighty prints all this text (Status: 200, etc...) to output - I think
than no other server then IIS needs this.
So, IIS surprised us in the same way as IE did some years ago when
we started web developing :-)

BUT DO NOT HURRY TO FIX IT! WE STILL DIDN'T CHECK IT WITH POST METHOD!
(that's what we are going to do next).
And I think our tester is too simple:
----------
class Gettest {
 public static function main()
 {
  neko.Lib.print("Status: 200 OK");
  neko.Lib.print("\n");
  neko.Lib.print("Content-type: text/html");
  neko.Lib.print("\n");
  neko.Lib.print("\n");
  trace(neko.Web.getParamsString());
 }
}
----------
It means that we have tested only "getParamsString" method of the
neko.Web class.

--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to