HTTP/1.0 allows an open-ended set of methods to be used
to indicate the purpose of a request.
The three most often used methods are GET, HEAD, and POST.
Information from a form using the GET method is
appended onto the end of the action URI being requested.
Your
CGI program
will receive the encoded form input in
the environment variable QUERY_STRING.
The GET method is used to ask for a specific document -
when you click on a hyperlink, GET is being used.
GET should probably be used when a URL access will not change
the state of a database
(by, for example, adding or deleting information)
and POST should be used when an access will cause a change.
Many database searches have no visible
side-effects and make ideal applications of query forms
using GET.
The semantics of the GET method changes to a
"conditional GET" if the request message includes an
If-Modified-Since header field.
A conditional GET method requests that the identified
resource be transferred only if it has been modified since the date
given by the If-Modified-Since header.
The HEAD method
The HEAD method is used to ask only for information about a
document, not for the document itself. HEAD is much faster than GET, as
a much smaller amount of data is transferred. It's often used by clients
who use caching,
to see if the document has changed since it was last accessed.
If it was not, then the local copy can be reused, otherwise the
updated version must be retrieved with a GET.
This method transmits all form input information immediately after
the requested URI.
Your
CGI program
will receive the encoded form input on stdin.
POST /cgi-bin/post-query HTTP/1.0
Accept: text/html
Accept: video/mpeg
Accept: image/gif
Accept: application/postscript
User-Agent: Lynx/2.2 libwww/2.14
From: Stars@WDVL.com
Content-type: application/x-www-form-urlencoded
Content-length: 150
* a blank line *
org=CyberWeb%20SoftWare
&users=10000
&browsers=lynx
This is a "POST" query addressed for the program residing
in the file at "/cgi-bin/post-query",
that simply echoes the values it receives.
The client lists the MIME-types it is capable of accepting,
and identifies itself and the version of the WWW library it is using.
Finally, it indicates the MIME-type it has used to encode the
data it is sending, the number of characters included, and the
list of variables and their values it has collected from the
user.
MIME-type application/x-www-form-urlencoded means that the
variable name-value pairs will be encoded the same way a URL is
encoded.
Any special characters, including puctuation,
will be encoded as %nn where nn
is the ASCII value for the character in hex.