cgi question (wodWebServer / wodWebServer.NET)
Could I call a cgi program by POST method?
The only example I could find in the sample file is:
User.Response.CGIExecute App.Path & MyCGI.bat
But how could I pass arguments to target program?
Thanks for your help!
Re: cgi question
Yes you can. You should read from stdin in your cgi app to retrieve request body.
Re: cgi question
Thanks for your quick response. The following is my html code which run on IIS 6.0. How could I go with wodWebServer?
[code]<html>
<head>
<title>Chat Example</title>
</head>
<body>
<script language= JavaScript >
<!--
function CheckForm ()
{
if (document.Chat.User.value == )
{
alert ( Please specify an user name! );
document.Chat.User.focus ();
}
else
document.Chat.submit ();
}
// -->
</script>
<form name= Chat action= http://localhost/cgi-bin/Chat.exe method= post >
Enter your name:
<input type= text name= User >
<input type= button value= Enter onclick= CheckForm () >
<input type= hidden name= Room value= Example >
<input type= hidden name= RefreshInterval value= 10 >
<input type= hidden name= MaxMessages value= 20 >
<input type= hidden name= Timeout value= 300 >
<input type= hidden name= ReturnFile value= / >
<input type= hidden name= StyleSheet value= Chat.ccs >
<input type= hidden name= Command value= Enter >
</form>
<script language= JavaScript >
<!--
document.Chat.User.focus ();
// -->
</script>
</body>
</html>
[/code]
Re: cgi question
Thanks for pointing out, I found out bug in wodWebServer. It should be fixed now. Can you please request update for wodWebServer, or download it again if you're evaluating it.
I didn't increate major version number yet, I will do it probably on next monday.
Your code should be as it was so far, such as [code]Private Sub Http1_RequestDone(ByVal User As WODWEBSERVERCOMLib.IWebUser)
If InStr(1, User.Request.URI, cgi-bin/Chat.exe ) Then
User.Response.CGIExecute yourcgi.exe
Else
User.Response.FileName = App.Path & \index.htm
End If
End Sub[/code]
and your CGI may look, for example, like this (C sample) [code] handle = open( output.txt , O_BINARY | O_WRONLY | O_CREAT, S_IREAD | S_IWRITE);
if (handle !=(-1))
{
lseek(handle, 0, SEEK_END);
while (gets(buff))
{
write(handle, buff, strlen(buff));
write(handle, \r\n , 2);
}
}
close(handle);
puts( Content-Type: text/html );
puts( );
printf( Done!\r\n , total);
[/code]
Let me know how it goes with new version
Kreso
Re: cgi question
Yes!
It does work!