标签:cgi pre 创建 war 设计 mode com post delete
方法表明了client希望server对资源运行的动作。经常使用的方法包含:GET、HEAD、POST、PUT、TRACE、OPTIONS和DELETE,每一个server能够实现这些方法中的部分或者所有。以下将对这些方法做一个具体的介绍。
GET /seasonal/index-fall.html HTTP/1.1 Host: www.joes-hardware.com Accept: *响应报文例如以下:
HTTP/1.1 200 OK Content-Type: text/html Context-Length: 617 //body
HEAD返回的首部应该和GET返回的首部全然同样。
PUT /product-list.txt HTTP/1.1 Host: www.joes-hardware.com Content-type: text/plain Content-length: 34 //body响应报文:
HTTP/1.1 201 Created Location: http://www.joes-hardware.com/product-list.txt Content-type: text/plain Context-length: 47 http://www.joes-hardware.com/product-list.txt
POST /inventory-check.cgi HTTP/1.1 Host: www.joes-hardware.com Content-type: text/plain Content-length: 18 item-bandsaw 2647服务端交由相应程序处理后,发送响应报文:
HTTP/1.1 200 OK Content-type: text/plain Context-length: 37 The bandsaw model 2647 is in stock!
TRACE请求会在目地server端发起一个“环回”诊断,行程最后一站的server会弹回一条TRACE响应,并在响应主体中带上收到的原始请求报文。这样client能够诊断原始报文是否被改动过。
请求报文:
TRACE /product-list.txt HTTP/1.1 Accept:* Host: www.joes-hardware.com报文经过代理server后:
TRACE /product-list.txt HTTP/1.1 Host: www.joes-hardware.com Accept: * Via: 1.1 proxy3.company.comserver弹回的TRACE响应:
HTTP/1.1 200 OK Content-type: text/plain Content-length: 96 TRACE /product-list.txt HTTP/1.1 Host: www.joes-hardware.com Accept: * Via: 1.1 proxy3.company.comTRACE响应经过代理server后:
HTTP/1.1 200 OK Content-type: text/plain Content-length: 96 Via: 1.1 proxy3.company.com TRACE /product-list.txt HTTP/1.1 Host: www.joes-hardware.com Accept: * Via: 1.1 proxy3.company.comTRACE方法主要用于诊断。它基本的缺陷是它假定中间应用程序对各种不同类型请求(GET、HEAD、POST等)的处理都是同样的,假设实际情况不同,那么诊断将不准确。
OPTIONS * HTTP/1.1 Host: www.joes-hardware.com Accept: *响应报文:
HTTP/1.1 200 OK Allow: GET, POST, PUT, OPTIONS Context-length: 0
请求报文:
DELETE /product-list.txt HTTP/1.1 Host: www.joes-hardware.com响应报文:
HTTP/1.1 200 OK Content-type: text/plain Content-length: 54 //响应消息
标签:cgi pre 创建 war 设计 mode com post delete
原文地址:http://www.cnblogs.com/mfmdaoyou/p/7259009.html