' CGI Echo
GLOBAL CONST nl = "\n"
CONST NumberOfCookies = 3
INCLUDE cgi.bas
OPTION cgi$Method cgi::Get OR cgi::Post
cgi::Header 200,"text/html"
FOR i = 1 TO NumberOfCookies
' cookie(i) is i, no domain is defined, path is /, expires after 10 seconds, not secure
cgi::SetCookie "cookie" & i, i, undef, "/", gmtime() + 10, false
NEXT
cgi::FinishHeader
'-------------------------------------------------------
PRINT """
<HTML>
<HEAD>
<title>CGI Echo</title>
</HEAD>
<BODY><font face="VERDANA" size="2">
<H1>View CGI Parameters</H1>
This page shows the CGI parameters the way it was uploaded.
<!-- here is the result of the previous HTTP request -->
<FONT SIZE="3">
<PRE>
CGI system variables
--------------------
"""
PRINT "ServerSoftware = ", cgi::ServerSoftware(), nl
PRINT "ServerName = ", cgi::ServerName(), nl
PRINT "GatewayInterface= ", cgi::GatewayInterface(),nl
PRINT "ServerProtocol = ", cgi::ServerProtocol(), nl
PRINT "ServerPort = ", cgi::ServerPort(), nl
PRINT "RequestMethod = ", cgi::RequestMethod(), nl
PRINT "PathInfo = ", cgi::PathInfo(), nl
PRINT "PathTranslated = ", cgi::PathTranslated(), nl
PRINT "ScriptName = ", cgi::ScriptName(), nl
PRINT "QueryString = ", cgi::QueryString(), nl
PRINT "RemoteHost = ", cgi::RemoteHost(), nl
PRINT "RemoteAddress = ", cgi::RemoteAddress(), nl
PRINT "AuthType = ", cgi::AuthType(), nl
PRINT "RemoteUser = ", cgi::RemoteUser(), nl
PRINT "RemoteIdent = ", cgi::RemoteIdent(), nl
PRINT "ContentType = ", cgi::ContentType(), nl
PRINT "ContentLength = ", cgi::ContentLength(), nl
PRINT "UserAgent = ", cgi::UserAgent(), nl
PRINT "Cookie = ", cgi::RawCookie(), nl
PRINT "Referer = ", cgi::Referer(), nl
PRINT "Password = ", Environ("HTTP_PASSWORD"), nl
PRINT "Full auth string= ", Environ("HTTP_AUTHORIZATION"), nl
PRINT "\nCookies:\n"
FOR i = 1 TO NumberOfCookies
PRINT "cookie" & i, " ", cgi::Cookie("cookie" & i), "\n"
NEXT
IF cgi::RequestMethod() = "GET" THEN
PRINT "GET text field using GetParam(\"TEXT-GET\") is ", cgi::GetParam("TEXT-GET"), nl
END IF
IF cgi::RequestMethod() = "POST" THEN
PRINT "POST text field using PostParam(\"TEXT-POST\") is ", cgi::PostParam("TEXT-POST"), nl
END IF
PRINT """
</PRE>
<TABLE>
<TR>
<TD BORDER=0 BGCOLOR="EEEEEE">
<PRE>
A simple form to POST parameters:<BR>
<FORM METHOD="POST" ACTION="/home/qbo/echo">
<INPUT TYPE="TEXT" VALUE="Default POST Field Text" NAME="TEXT-POST">
<INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" POST ">
</FORM>
</PRE>
</TD>
<TD BORDER=1 width="20"> </TD>
<TD BORDER=0 BGCOLOR="EEEEEE">
<PRE>
A simple form to GET parameters:<BR>
<FORM METHOD="GET" ACTION="/home/qbo/echo">
<INPUT TYPE="TEXT" VALUE="Default GET Field Text" NAME="TEXT-GET">
<INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" GET ">
</FORM>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
"""