nathan242/php-icap-client

互联网内容适配协议 (ICAP) 客户端库

v0.5.1 2023-07-02 13:49 UTC

This package is not auto-updated.

Last update: 2024-09-22 19:10:18 UTC


README

PHP ICAP 客户端。

允许您从 PHP 发送请求到互联网内容适配协议 (ICAP) 服务器。

用法

使用 ICAP 服务器地址和端口实例化类

$icap = new IcapClient('127.0.0.1', 13440);

向 "example" 服务发送 OPTIONS 请求

$icap->options('example');

向 "example" 服务发送 REQMOD 和 RESPMOD 请求

$icap->reqmod(
    'example',
    [
        'req-hdr' => "POST /test HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n",
        'req-body' => 'This is another test.'
    ]
);

$icap->respmod(
    'example',
    [
        'res-hdr' => "HTTP/1.1 200 OK\r\nServer: Test/0.0.1\r\nContent-Type: text/html\r\n\r\n",
        'res-body' => 'This is a test.'
    ]
);

成功的请求将返回一个描述响应的数组

Array
(
    [protocol] => Array
        (
            [icap] => ICAP/1.0
            [code] => 200
            [message] => OK
        )

    [headers] => Array
        (
            [Date] => Wed, 03 Jul 2019 22:11:33 GMT
            [ISTag] => X7K07GDZQW702ZVLSG6WWO0EPE2CTOMR
            [Encapsulated] => res-hdr=0, res-body=64
            [Server] => ICAP/1.3 Python/2.7.3
        )

    [body] => Array
        (
            [res-hdr] => HTTP/1.1 200 OK
content-type: text/html
server: Test/0.0.1
            [res-body] => This is a test.
        )

    [rawBody] => HTTP/1.1 200 OK
content-type: text/html
server: Test/0.0.1

f
This is a test.
0


)