HTTP with
CGI As
discussed in the previous article s the importance of HTML, HTTP, and CGI
together in the creation of a web page, here in this article we discuss the
role of HTTP. We all know from the previous article that it the work of HTML to
collect
data from the client side and send this data to the host side or to the
CGI program. But the question and the importance of HTTP arrive here. How the
data does reach the host side- the answer is HTTP.
This
magic of sending the gathered data to the CGI
program is done by HTTP headers.
Here the HTML tags come into action. These HTML tags tell the browser what type
of HTTP header to use to talk to the server- CGI program. The basic HTTP
headers for starting the communication with the host side or the CGI program
are Get
and Post
headers.
If
a hypertext HTML link is calling your program, then the HTTP
request method Get
is
used to communicate the request to the
server side- CGI program, and this
header Get is used by default. An example:
<a href="www.xper.com/program.cgi">,
call a CGI program </a>
In case, the form tag is defined for post
then, a Post method request header is used to
communicate with your CGI program.
After
the method of sending the data is fixed, the data is configured and sent by one
of the get or post methods. If the Get method is used in sending the data,
the data is sent through a Uniform Resource Identifier (URI)
field. If the Post method is used in sending the data, the
data is sent as a separate message, after all the other HTTP request headers
have been sent out to the host side.
After
it has been decided as to how to send the data, whether by Get pr post, the
browser makes a HTTP request header to the location where the CGI program is
located. After receiving the HTTP
request, the server calls the CGI program. Several other request headers can also
go along with the request header to give the server and your CGI program more useful
data from the browser and client side.
The
CGI program now performs some function according to the request and then tells
the server what type of response it wants to send back to the server. The
server and the CGI program together send HTTP response headers back to the
client side. The HTTP response headers come into use over here. They tell the
client browser what type of information is coming back from the host server.
Therefore,
now you can imagine how the whole thing works. HTML formats the data; HTTP
sends the data, CGI works on it, sends it back with the help of HTTP and it
translates the data into a meaningful one!
More summaries about the HTTP with CGI