Thursday, December 27, 2012

HTTP-Request-headers/HTTP-Response-headers


Servlet Example: Showing Request Headers

Request Method: GET
Request URI: /servlet/ShowRequestHeaders.do
Request Protocol: HTTP/1.1

Header NameHeader Value
hostlocalhost:8080
connectionkeep-alive
user-agentMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4
accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-encodinggzip,deflate,sdch //Gzip is a text compression scheme that can dramatically reduce the size of HTML

accept-languageen-US,en;q=0.8
accept-charsetISO-8859-1,utf-8;q=0.7,*;q=0.3
cookieemail=charlesxieyupeng%40gmail.com


A typical request look like

E.X.
GET /servlet/Search?keywords=servlets+jsp HTTP/1.1
Accept : image/gif, image/jpg, */*
Accept-Encoding: gzip
Connection: Keep-Alive
Cookie : userID=id456578
POST..

A typical response header


Status Code

• 100–199
Codes in the 100s are informational, indicating that the client should 
respond with some other action. 
• 200–299
Values in the 200s signify that the request was successful. 
• 300–399
Values in the 300s are used for files that have moved and usually 
include a Location  header indicating the new address. 
• 400–499
Values in the 400s indicate an error by the client
• 500–599
Codes in the 500s signify an error by the server





No comments:

Post a Comment