HTTP Basics
HTTP Basics
HTTP stands for Hyper Text Transfer Protocol which is an application level protocol
for transferring textual data between client and server.
Web Client such as web browser sends the request to server, server responds and
sends the requested data (such as a HTML document) or returns error code and closes
the connection. Once the response is returned, server doesn�t remember anything
about the client.(even the very next request)
After the client sends the request, server processes the request and sends the
response.
Following is an example of HTTP request which uses GET request method to ask for a
HTML document named tutorial.html using HTTP protocol version 1.1
Above header specifies the information about the client software and what
MIME(Multi-purpose Internet Mail Extension) type the client accepts in response,
using User-Agent and Accept headers.
The request method indicates to the server what action to perform on the resource
identified by the request-URI.
The GET request is used typically for getting static information from the server
such as HTML document, images, and CSS files.
It can be used to retrieve dynamic information also by appending query string at
the end of request URI.
Query String
Query string is used to pass additional request parameters along with the request.
URL?name1=value1&name2=value&name3=value3 �.
eg -- http://www.abc.com/test/login.jsp?userid=10&name=abc&age=25
The POST request method is typically used to access OR create new dynamic
resources.
GET Vs POST
1.
GET request sends the request parameters as query string appended at the end of the
request URL, whereas POST request sends the request parameters as part of the HTTP
request body.
2.Unlike GET, POST request sends all the data as part of the HTTP request body, so
it doesn�t appear in browser address bar and cannot be bookmarked.
In practice it is often not possible to implement safe methods in a way they do not
alter any server state.
eg : a GET request might create log or update statistic values or trigger a cache
refresh on the server.
Idempotency means that multiple identical requests will have the same outcome. So
it does not matter if a request is sent once or multiple times.
The following HTTP methods are idempotent: GET, HEAD, OPTIONS, TRACE, PUT and
DELETE.
All safe HTTP methods are idempotent but PUT and DELETE are idempotent but not
safe.
Note that idempotency does not mean that the server has to respond in the same way
on each request.
The following table summarizes which HTTP methods are safe and idempotent: