Jak*_*ake 7 php ssl https curl zend-framework
我正在使用Zend_HTTP_Client将HTTP请求发送到服务器并获得响应.我发送请求的服务器是HTTPS Web服务器.目前,一次往返请求大约需要10-12秒.我理解开销可能是因为请求所依赖的Web服务器的处理速度很慢.
是否有可能像我们在CURL中那样跳过SSL证书检查以加快性能?如果是这样,如何设置这些参数?
我有以下代码:
try
{
$desturl ="https://1.2.3.4/api";
// Instantiate our client object
$http = new Zend_Http_Client();
// Set the URI to a POST data processor
$http->setUri($desturl);
// Set the POST Data
$http->setRawData($postdata);
//Set Config
$http->setConfig(array('persistent'=>true));
// Make the HTTP POST request and save the HTTP response
$httpResponse = $http->request('POST');
}
catch (Zend_Exception $e)
{
$httpResponse = "";
}
if($httpResponse!="")
{
$httpResponse = $httpResponse->getBody();
}
//Return the body of HTTTP Response
return $httpResponse;
Run Code Online (Sandbox Code Playgroud)
Chr*_*nry 10
如果您确信SSL
是问题,那么您可以配置Zend_Http_Client
使用curl
,然后传入适当的curl
选项.
http://framework.zend.com/manual/en/zend.http.client.adapters.html
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(CURLOPT_SSL_VERIFYPEER => false),
);
$client = new Zend_Http_Client($uri, $config);
Run Code Online (Sandbox Code Playgroud)
我实际上建议使用curl
适配器,因为curl
几乎所有你需要的选项,Zend确实提供了一个非常好的包装器.
归档时间: |
|
查看次数: |
8489 次 |
最近记录: |