No return from "post" on Linux? A bug?
Sadhunathan Nadesan
sadhu at castandcrew.com
Thu Jan 30 21:16:01 EST 2003
Greetings Scott,
Not sure actually if this is a bug report, or I am doing something wrong,
a library mismatch, or maybe, just a request for a 'how to do it the
right way'?? In any case I would appreciate any advice.
Context:
I have a stack that does a post command to a cgi script on a remote
server. The cgi runs some sql queries to standard out (it has of course
first set the correct html content type so that apache likes the output).
Problem:
On Windows, the sql output is returned as "it" right after the post
command in the calling stack.
On Linux, this does not happen. Nothing is returned.
More Details:
I can confirm that the cgi is being called, that the sql is being
invoked, and I can save the output in a temporary file from this cgi
(which is an MC script) or even read this file back in to a buffer,
but then when I do a 'put' of this buffer, it does not return to the
calling stack on the remote client.
Again, only if it is a Linux client. It does return just fine to a
Windows client.
The stack itself was created using MC 2.4.3 and the MC interpreter on
the webhost is 2.4 if that could be the problem, but it seems like the
post would not work at all to invoke the cgi if it were.
Anyway, any thoughts? I can provide more details as needed. Code samples
below.
Gracias,
Sadhu
----- code sample, the calling stack ----
on AzzList
AzzClear
set the listBehavior of field "contents" to true
put "action=list&" into azzdata
set httpheaders to "Content-type: application/x-www-form-urlencoded" & return
# the real name of the host has been replaced to protect the innocent
post urlEncode(azzdata) to url ("http://localhost.com/cgi-bin/azz.cgi")
put it into sqldata
if (the number of characters in sqldata is zero) then
answer "Sorry, your data base is empty" & cr
else
put "In the contents field below is a list of all the card titles" into field "title"
put sqldata into field "contents"
end if
end AzzList
----- code sample, the cgi stack ----
#!/usr/local/bin/mc
on startup
put "Content-Type: text/plain" & cr & cr
put emtpy into formdata
if ($REQUEST_METHOD = "POST") then
put empty into buffer
repeat until (length(buffer) >= $CONTENT_LENGTH)
read from stdin until empty
put it after buffer
end repeat
else
read from stdin until empty
put it into buffer
end if
put urlDecode(buffer) into formdata
split formdata by "&" and "="
put keys(formdata) into keywords
switch formdata["action"]
case list
put "select title from azz order by title;" into the_query
put the_query into url "file:/tmp/azzlist.sql"
put "psql azz -qt -f /tmp/azzlist.sql" into command_string
break
end switch
set shellCommand to "/bin/sh"
put shell(command_string)
end startup
More information about the metacard
mailing list