开发者

Zend_Http_Client Requests failing with Fiddler Proxy

开发者 https://www.devze.com 2023-02-12 16:46 出处:网络
I\'ve written a simple spider to test various things with Fiddler. The script makes a few requests with Zend_Http_Client->request() using the same instance of the Zend_Http_Client class ($client in th

I've written a simple spider to test various things with Fiddler. The script makes a few requests with Zend_Http_Client->request() using the same instance of the Zend_Http_Client class ($client in the example below).

When using Fiddler and Zend_Http_Client, only the first Zend_Http_Client->request() works; subsequent requests fail with "Unable to read response, or response is empty". Here's my Zend_Http_Client configuration with Fiddler:

$config = array(
    'adapter'       => 'Zend_Http_Client_Adapter_Proxy',
    'proxy_host'    => '127.0.0.1',
    'proxy_port'    => 8888,
    'timeout'       => 60,
    'useragent'     => 'Local Site Spider Test',
    'keepalive'     => true,
    'sslusecontext' => true
);

$client = new Zend_Http_Client('http://www.site.com/',  $config);

Here's a simplified example of what would fail, using $client from above:

$response = $client->request();
echo $response->getHeadersAsString();

$client->setUri('http://www.s开发者_运维知识库ite.com/file.html');
$response = $client->request();
echo $response->getHeadersAsString();

The spider itself works 100% as intended when not using a proxy, so the code itself is fine. Fiddler is also working, capturing all requests from all processes (tested with WinInet as well as various browsers).

0

精彩评论

暂无评论...
验证码 换一张
取 消