HTTP

HTTP
stateless: request-response

request:
Http command, address of a document(URL), version of http protocol
GET /intro.html HTTP/1.0

response:
version of http protocol, status code, description of status code

HTTP/1.0 200 OK
date
servertype
mime version
content type
content length
last modified

Methods
GET: appears in requesting URL, bookmarkable, sendalble many times, short "(e.g. 240 character) meant for getting something from server
POST: exchanged via sockets, sent only once, long(up to mega bytes)  meant for posting something to the server and updating
HEAD: just get the header: to determine document size, last modified date or general availability
TRACE:
PUT: place documents directly on server -- not widely supported due to policy issues
DELETE: reverse as put
OPTIONS: ask server which methods it supports, o rehat options are available for a particular resource on the server.

GET, HEAD, PUT are assumed idempotent by HTTP    POST is not assumed to be idempotent
idempotent: in Http / Servlet terms it means that the same request can be made twice without any negative consequences on the server. We don't mean that the same request always returns the same response and we do not mean that the request doesn't have any side effects.

Connections

When a client, such as a browser, wants to request a web document from a server, it begins by establishing a
socket connection to the server. Over this connection, the client makes its request and then receives the
server's response. The client indicates it has finished its request by sending a blank line; the server, in turn,
indicates that the response is complete by closing the socket connection.
So far, so good. But what if the retrieved page contains <IMG> tags or <APPLET> tags that require the client
to retrieve more content from the server? Well, another socket connection is used. If a page contains 10
graphics along with an applet made up of 25 classes, that's 36 connections needed to transfer the page. No
wonder some people say WWW stands for the World Wide Wait! This approach is like ordering a pizza, but
making a separate phone call for each topping.
By setting the content length, the client waits until that amount has been received, hence, sending more than one data per connection.

HTTP Response
Cache-Control
Pragma : nocache
Connection: Keep-Alive or Close  to show persistent connections
Retry-After
Expires


to rediret:
res.setStatus(res.SC_MOVED_TEMPORARILY);
res.setHeader("Location", "http://www.yahoo.com");


Comments