Re: CGI and euc
- Posted by bugmagnet Jan 14, 2013
- 2306 views
This works
-- suck.ex (suck eggs) include std/net/url.e include std/filesys.e include std/dll.e include std/machine.e constant KEYB = 0, SCREEN = 1 constant TRUE = 1, FALSE = 0 -- set up C routines that we need: atom kernel32 = open_dll("kernel32.dll") if kernel32 = 0 then puts(SCREEN, "Can't open kernel32.dll!\n") abort(1) end if integer GetStdHandle = define_c_func(kernel32, "GetStdHandle", {C_LONG}, C_INT) if GetStdHandle = -1 then puts(1, "Can't find GetStdHandle\n") abort(1) end if integer WriteFile = define_c_func(kernel32, "WriteFile", {C_POINTER, C_POINTER, C_INT, C_POINTER, C_POINTER}, C_INT) if WriteFile = -1 then puts(1, "Can't find WriteFile\n") abort(1) end if sequence code = "HTTP/1.1 200 OK\r\n" & "Cache-Control: no-cache\r\n" & "Content-type:text/javascript\r\n" & "\r\n" & "console.log('" & getenv("QUERY_STRING") & "');\r\n" atom string_pointer = allocate(length(code)+1) poke(string_pointer, code & 0) atom byref = allocate(4) poke4(byref, 0) atom z = c_func(GetStdHandle,{-11}) atom x = c_func(WriteFile, {z, string_pointer, length(code), byref, 0}) free(string_pointer)
This doesn't work
-- suck.ex (suck eggs) puts(1, "HTTP/1.1 200 OK\r\n" ) puts(1, "Content-Type: text/javascript\r\n" ) puts(1, "Cache-Control: no-cache\r\n") puts(1, "\r\n" ) puts(1, "console.log('QUERY_STRING=" & getenv("QUERY_STRING") & "');\r\n")
I'm using HTTP 1.1 in both cases. The "pure" Euphoria fails. The version using Win32 API works. Weird.
Bugmagnet.