#1 2008-01-22 05:44:54
- Northie
- Moderator

- From: Yorkshire, UK
- Registered: 2006-08-19
- Posts: 2607
- I've been thanked 63 times.
-

GET and POST
Note that this post is in the Good Site Building Practices Section of this forum
I've noticed a lot of people who are getting into server side programming, both on this forum and elsewhere, are mis-using the GET and POST request methods; probably not even knowing that these methods exist, what they are and how they differ.
The w3c have set out some standards and specifications on how it should be done:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
In particular, note this part
W3C wrote:
In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe".
So what is a GET?
GET, in this instance means getting information from the server.
Details about information required are sent via the request URI (URL to most people), usually containing variables in the form
?variable=value&.....
As this is the way in which most servers are set up to interpret GET requests.
These are "real" URLs that should not invoke an action on the server, and certainly not one that modifies data. The concept of a GET request is to get information and display it in the browser
what is POST?
A post request is similar to a GET request only in that a set of variable:value pairs are sent to the server from the client.
Most commonly, these are set by the client when a form is filled in and submitted.
Here the resulting page is not accessible through a URI, as the request variables are sent in a different part of the header.
POST is posting information to the server that the server should process and store. By definition, POST changes the state of the server, while GET should not.
There are other possible methods such as PUT, DELETE and HEAD.
PUT and DELETE are not used very often and modern clients and servers may not support them, but they are there in the standard specification.
a HEAD request can be useful for getting just the response status code (eg 200, 404, 500, 301, 302, 304, etc) where the body is no needed.
For example, 304 means "Not modified"; so if you're requesting information form the server that hasn't changed since the last time you requested it, the client should use the most recent cached copy, rather than make a new request. Conversely, if a 100 is received, this means continue; the client should make the request that, if successful, would return content with a 200 OK status.
More on status codes can be found here
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
HEAD may not be fully supported by all clients and servers
Now taking free-lance inquiries; Please contact me for more details
Internet Marketing Books
Promote Yourself on Site Reference!
Offline
| Never |
- Sponsored Results
|
|