2010-07-30 66 views
3

我正在使用Zend_HTTP_Client向服务器发送HTTP请求并获取响应。我发送请求的服务器是HTTPS Web服务器。目前,一个往返请求需要大约10-12秒。我了解,开销可能是因为请求发送到的Web服务器处理缓慢。跳过SSL签入Zend_HTTP_Client

是否可以像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; 
+0

您猜测性能问题可能是什么?为什么不确定? – 2010-07-30 00:17:34

回答

6

如果你确信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); 

其实,我建议使用curl适配器,只是因为curl有相当多,你永远需要每一个选项,Zend公司确实提供了一个非常好的包装。