现在的位置: 首页 > 综合 > 正文

ICAP请求和响应实例分析(REQMOD 请求方式)

2019年01月12日 ⁄ 综合 ⁄ 共 3930字 ⁄ 字号 评论关闭

 

参考如下实例,一个surrogate(代理) 收到一个来自client 端的请求。

首先surrogate(代理)会做为一个ICAP client 向ICAP server 发送modification(变更)请求,ICAP server 修改了请求的头部,然后将修改后的头返回给ICAP client。

我们假设ICAP server 会修改多个头部,并且从源请求中去掉cookie。

在以下的例子中,我们包含了一些meta-data(元数据)到消息中,为了适应以块封装的消息体,如果有的话。我们假设end-of-line terminations(换行符),空行都是two-byte "CRLF" sequences.(两个字节)

例1:

   ----------------------------------------------------------------

   ICAP Request Modification Example 1 - ICAP Request
   说明:这是ICAP client发送的请求部分,其中Encapsulated: req-hdr=0, null-body=170 这部分内容,req-hdr=0 表示请求头部的offset(偏移量)为0,null-body=170表示没有body,只有头部,170指头部大小即“GET / HTTP/1.1 .....If-None-Match: "xyzzy", "r2d2xxxx" ”这部分的长度是170bytes。

   ----------------------------------------------------------------

   REQMOD icap://icap-server.net/server?arg=87 ICAP/1.0
   Host: icap-server.net
   Encapsulated: req-hdr=0, null-body=170

   GET / HTTP/1.1
   Host: www.origin-server.com
   Accept: text/html, text/plain
   Accept-Encoding: compress
   Cookie: ff39fk3jur@4ii0e02i
   If-None-Match: "xyzzy", "r2d2xxxx"

 

   ----------------------------------------------------------------
   ICAP Request Modification Example 1 - ICAP Response

   说明:这是ICAP server发送的响应内容,Encapsulated 这部分说明同上。server 对请求头部分的modification 包括:修改了GET 后路径,去掉了cookie的内容,添加了一个service
   ----------------------------------------------------------------
   ICAP/1.0 200 OK
   Date: Mon, 10 Jan 2000  09:55:21 GMT
   Server: ICAP-Server-Software/1.0
   Connection: close
   ISTag: "W3E4R7U9-L2E4-2"
   Encapsulated: req-hdr=0, null-body=231

   GET /modified-path HTTP/1.1
   Host: www.origin-server.com
   Via: 1.0 icap-server.net (ICAP Example ReqMod Service 1.1)
   Accept: text/html, text/plain, image/gif
   Accept-Encoding: gzip, compress
   If-None-Match: "xyzzy", "r2d2xxxx"

 

例2:

   ----------------------------------------------------------------
   ICAP Request Modification Example 2 - ICAP Response

   说明:第二个例子和第一个很相似,只是请求方式从get变成了post。注意encapusulated(封装)content-length(内容长度)参数已经被修改了,来反映修改的body的消息。外部的ICAP消息不需要content-length 头,因为它采用了chunking(分块)方式。

   在这个例子里,encapusulated(封装)的标题为请求和响应展示了分层的,转发头和转发body。

   ----------------------------------------------------------------
   REQMOD icap://icap-server.net/server?arg=87 ICAP/1.0
   Host: icap-server.net
   Encapsulated: req-hdr=0, req-body=147

   POST /origin-resource/form.pl HTTP/1.1
   Host: www.origin-server.com
   Accept: text/html, text/plain
   Accept-Encoding: compress
   Pragma: no-cache

   1e
   I am posting this information.
   0

   ----------------------------------------------------------------
   ICAP Request Modification Example 2 - ICAP Response
   ----------------------------------------------------------------
   ICAP/1.0 200 OK
   Date: Mon, 10 Jan 2000  09:55:21 GMT
   Server: ICAP-Server-Software/1.0
   Connection: close
   ISTag: "W3E4R7U9-L2E4-2"
   Encapsulated: req-hdr=0, req-body=244

   POST /origin-resource/form.pl HTTP/1.1
   Host: www.origin-server.com
   Via: 1.0 icap-server.net (ICAP Example ReqMod Service 1.1)
   Accept: text/html, text/plain, image/gif
   Accept-Encoding: gzip, compress
   Pragma: no-cache
   Content-Length: 45

   2d
   I am posting this information.  ICAP powered!
   0

例3:

   ----------------------------------------------------------------

   ICAP Request Modification Example 3 - ICAP Request

   第三个例子,显示ICAP server 返回了一个错误响应,当它收到一个变更请求。

   ----------------------------------------------------------------

   REQMOD icap://icap-server.net/content-filter ICAP/1.0
   Host: icap-server.net
   Encapsulated: req-hdr=0, null-body=119

   GET /naughty-content HTTP/1.1
   Host: www.naughty-site.com
   Accept: text/html, text/plain
   Accept-Encoding: compress

   ----------------------------------------------------------------

   ICAP Request Modification Example 3 - ICAP Response
   ----------------------------------------------------------------

   ICAP/1.0 200 OK
   Date: Mon, 10 Jan 2000  09:55:21 GMT
   Server: ICAP-Server-Software/1.0
   Connection: close
   ISTag: "W3E4R7U9-L2E4-2"
   Encapsulated: res-hdr=0, res-body=213

   HTTP/1.1 403 Forbidden
   Date: Wed, 08 Nov 2000 16:02:10 GMT
   Server: Apache/1.3.12 (Unix)
   Last-Modified: Thu, 02 Nov 2000 13:51:37 GMT
   ETag: "63600-1989-3a017169"
   Content-Length: 58
   Content-Type: text/html

   3a
   Sorry, you are not allowed to access that naughty content.
   0

 

抱歉!评论已关闭.