29 CGI data transmission
..A browser can send data to the server. Most commonly, the data is simply the address
of a URL
the server to
of a form, the browser can
send data to the server without using a form.
There are two possible formats
send such data
get or post. In both cases, the
browser send the URL of a program that will be used to process the data, followed
by the data itself. The two formats, get and post, differ
how the data is sent.
Here are examples of the strings sent from the browser to the server using the get format. In
example, the words
are sent, as is the string
Everything up to the question mark is the full path name of the application to be run by the server.
Everything after the question mark is called the query string or the search string. It consists of name
pairs, separated by question marks. See below
special formatting rules.
The server runs the application. It also passes the application the search string
The application returns results to the web server
the form of a text stream
usually a complete
HTML document, although it could be simply a image to
to the browser.
The GET method is usually limited by the browser to a few thousand characters.
The query string is formatted
a special way
Special characters, including spaces, must be replaced by their hexadecimal characters.
Spaces can also be replaced by the plus sign
The CGI application that receives the data has to be able to interpret the query string, decoding the
special characters as well as extracting all of the name pairs
The post method sends a special header after the URL, tellling the server how many bytes of data will
follow. The data transmission then follows the header. No limit applies to the number of bytes that may