|
|
An Introduction to CGI - The Common Gateway Interface
by Jay Eckles
Request Methods
While several methods are defined in the HTTP specification, only two
are commonly used for CGI. The first is GET, the second is POST. Other
methods specified in HTTP 1.1 (see RFC 2068 at http://www.w3c.org/P
rotocols/rfc2068/rfc2068) include OPTIONS, PUT, HEAD, DELETE, and
TRACE. You can tell which method was used by inspecting the environment
variable REQUEST_METHOD. As a rule of thumb, any time the request is the
result of a user clicking on a link or directly entering a URL, the
request method is GET. When the request is the result of a form
submission, the request method is the same as the value of the method
attribute in the form tag of the html document containing the form. Note
that HTTP request methods are case-sensitive.
Many people write or use pre-written libraries that aid in retrieving
the input for their gateway program. At minimal, such a library should
provide functions for automatically determining the request method and
retrieving the input; however, most libraries go far beyond this minimal
functionality. You should seek out such libraries to assist you in
writing your code; they will help you avoid common pitfalls and bugs and
more importantly some of the more subtle security holes.
[Contents] [Next] [Previous]
If you have any questions or would like to contact me for any reason, please email me at j.eckles@computer.org.
|