2. Hyper Text Transfer Protocol
3. Http 1.0, and 1.1, now normally using 1.1
http1.0: short time connection, disconnect immediately
http1.1: longer time connection, 30 seconds
Request Header
GET /test/hello.html HTTP/1.1
Accept: */*
Referer: http://localhost:8080/test/abc.html
Accept-Language: zh-cn
User-Agent: Mozilla/4.0
Accept-Encoding: gzip, deflate
Host: localhost:8080
Connection: Keep-Alive
[empty line]
dataname1=data1
dataname2=data2
- Accept: text/html, image/*
- Accept-Charset: ISO-8859-1
- Accept-Encoding: gzip, compress
- Accept-Language: en-us,zh-cn
- Host: www.sohu.com:80
- If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT //cache time, refresh if there is newer
- Referer: http://www.sohu.com/index.jsp //tell host where this request come from, prevent spam
- User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
- Cookie
- Connection: close // or Keep-Alive
- Date: Tue, 11 Jul 2000 18:23:51 GMT
Request Methods:
POST GET HEAD OPTIONS DELETE TRACE PUT
Response Header
- HTTP/1.1 200 OK
- Location: http://www.baidu.com //tell browser to redirect new url
- Server: apache tomcat
- Content-Encoding: gzip
- Content-Length: 80
- Content-Language: zh-cn
- Content-Type: text/html; charset=GB2312 //response.setContentType("text/html;charset=GB2312");
- Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT
- Refresh: 1;url=http://www.baidu.com //redirect to url after 1 second
//response.setHeader("Refresh", "5;url=http://www.sohu.com"); - Content-Disposition: attachment; filename=aaa.zip
//tell browser that there is file to download
//response.setHeader("Content-Disposition","attachment; filename=aaa.zip"); - Transfer-Encoding: chunked //checksum verified
- Set-Cookie:SS=Q0=5Lb_nQ; path=/search //to be introduced
- Expires: -1 //tell browser(IE) how to cache data
- Cache-Control: no-cache //tell browser(FireFox) how to cache data
- Pragma: no-cache //tell browser(some browser) how to cache data
//response.setDateHeader("Expires",-1); //or value to System.currentTimeMillis()+1*1000;
//response.setHeader("Cache-Control","no-cache");
//response.setHeader("Pragma","no-cache"); - Connection: close/Keep-Alive
- Date: Tue, 11 Jul 2000 18:23:51 GMT
State Code
- 200 normal
- 302 server request browser redirect to another resource
response.sendRedirect("anotherPage")
// or response.setStatus(302); response.setHeader("Location","anotherPage"); - 404 not found
- 500 server error
throw new RuntimeException();
No comments:
Post a Comment