Get & Post
Home ] Up ] InfoSpace Example ] Google Maps Example ] [ Get & Post ]

 

 

There are two basic methods for performing CGI queries:

  • GET, and
  • POST

(Actually, there are a number of additional methods, but we will ignore these others for the purposes of this discussion.)

The CGI GET Method

The protocol for an HTTP GET method is for the client to send a request message to the web server that looks something like:

GET /images/logo.gif HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)
Host: www.rivier.edu
Connection: Keep-Alive

followed by a blank line.

In the above GET request message, the first line requests a file logo.gif from the web server.  The file is expected to be located in the images folder.

If any CGI query string is present, it is appended to the URL in the first line.  Problems with this include:

  • The entire URL is usually displayed in the Address field of the browser, so any sensitive information (such as passwords) are too visible.
  • Every browser (and probably every web server) has some upper limit on the size of a URL, including any query string, so there is a limit on how much data can be passed using this method.

The lines following the first line, and preceding the blank line are Request Headers (one request header per line).

The CGI POST Method

The POST method attempts to solve these problems by moving the name/value pairs that comprise the query string into the main body of the request message:

POST /cg-bin/queryProcessor HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)
Host: www.rivier.edu
Connection: Keep-Alive

name=Bryan
college=Rivier

Which allows larger amounts of data to be passed in the message.

The data inside the message is also not displayed in the browser's address field.

 

The page was last updated February 19, 2008