当我尝试打开连接时HTTP_Request
抛出:
畸形响应:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
仅当站点与脚本位于同一服务器上时。
有谁知道为什么会发生这种情况或如何解决?
<?php
require_once 'HTTP/Request2.php';
$hosts = array('http://example.com', 'http://site_on_my_vps.com' );
$status = array();
foreach($hosts as $host){
$request = new HTTP_Request2( $host , HTTP_Request2::METHOD_GET);
$status[ $host ] = array( );
try {
$response = $request->send();
$rbody = $request->getBody();
$status[ $host ]['status']= $response->getStatus();
$status[ $host ]['bodysize']=strlen( $rbody );
} catch (HTTP_Request2_Exception $e) {
$status[ $host ]['error'] = $e->getMessage();
}
}
print_r($status);
更新:添加代码