Show
Ignore:
Timestamp:
09/11/08 23:23:12 (4 months ago)
Author:
sasezaki
Message:

lang/php/ZendFramework_ext: Diggin_Http_Client_Adapter_TestPlus, コネクションタイム偽装処理(仮)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/ZendFramework_ext/library/Diggin/Http/Client/Adapter/TestPlus.php

    r18901 r19199  
    6363     
    6464    /** 
    65      * size of response 
    66      * 
    67      * @var unknown_type 
     65     * random status 
     66     * 
     67     * @var array 
    6868     */ 
    6969    protected $_statusRandom; 
     70     
     71     
     72    protected $_connectiingTime = 0; 
    7073     
    7174        /**     * 
     
    7477    protected $_randomResponseBodyInterval; 
    7578 
    76      
     79    /** 
     80     * test response Body 
     81     * 
     82     * @var array 
     83     */ 
    7784    protected $_testResponseBody = array(); 
    7885     
     
    8693    { 
    8794        if (is_null($resposeBody)) { 
    88             $resposeBody = <<<RESPONSEBODY 
    89 <html lang="ja"> 
    90 <head> 
    91 <body> 
    92 this is testplus<br /> 
    93 </body> 
    94 </html> 
    95 RESPONSEBODY; 
     95            $resposeBody = '<html lang="ja">'.PHP_EOL. 
     96                           '<head>'.PHP_EOL. 
     97                           '<body>'.PHP_EOL. 
     98                           'this is testplus<br />'.PHP_EOL. 
     99                           '</body>'.PHP_EOL. 
     100                           '</html>'; 
    96101        } 
    97102         
    98103        if (is_null($responseHeader)) { 
    99            $responseHeader = <<<RESPONSEHEADER 
    100 HTTP/1.1 200 OK 
    101 Date: Sat, 02 Aug 2008 15:17:11 GMT 
    102 Server: Apache/2.2.6 (Win32) mod_ssl/2.2.6 OpenSSL/0.9.8e PHP/5.2.5 
    103 Last-modified: Sun, 29 Jun 2008 21:20:50 GMT 
    104 Accept-ranges: bytes 
    105 Content-length: 1000 
    106 Connection: close 
    107 Content-type: text/html 
    108 RESPONSEHEADER; 
     104           $responseHeader =  
     105           "HTTP/1.1 200 OK"        ."\r\n". 
     106           "Date: Sat, 02 Aug 2008 15:17:11 GMT"."\r\n". 
     107           "Server: Apache/2.2.6 (Win32) mod_ssl/2.2.6 OpenSSL/0.9.8e PHP/5.2.5"."\r\n". 
     108           "Last-modified: Sun, 29 Jun 2008 21:20:50 GMT"."\r\n". 
     109           "Accept-ranges: bytes"   . "\r\n" . 
     110           "Content-length: 1000"   . "\r\n" . 
     111           "Connection: close"      . "\r\n" . 
     112           "Content-type: text/xml"; 
     113            
    109114        } 
    110115         
     
    140145    public function connect($host, $port = 80, $secure = false) 
    141146    {  
    142         //require_once 'Zend/Http/Client/Adapter/Exception.php'; 
    143         //throw new Zend_Http_Client_Adapter_Exception('Unable to set the connection timeout'); 
     147        //fake time out 
     148        sleep($this->_connectiingTime); 
     149        if ($this->_connectiingTime > (int) $this->config['timeout']) { 
     150            require_once 'Diggin/Http/Client/Adapter/Exception.php'; 
     151            throw new Diggin_Http_Client_Adapter_Exception('Unable to set the connection timeout(fake)'); 
     152        } 
    144153    } 
    145154 
     
    300309        $this->_statusRandom = $config; 
    301310    } 
    302    
    303     //@todo 
    304     public function setConnectionTime($time, $randomFlg = false) 
    305     { 
    306                  
     311     
     312    /** 
     313     * set connect time 
     314     * 
     315     * @param int $time  
     316     */ 
     317    public function setConnectingTime($time) 
     318    { 
     319        $this->_connectiingTime = $time; 
    307320    } 
    308321     
     
    314327        //@todo array_shift(func_get_args)         
    315328        if (is_null($addResponseBody)) { 
    316         $addResponseBody = <<<RESPONSEBODY 
    317 <html lang="ja"> 
    318 <head> 
    319 <body> 
    320 This is testplus <br /> 
    321 222222222222222222 
    322 </body> 
    323 </html> 
    324 RESPONSEBODY; 
    325 //$_testResponseBody[2] = <<<RESPONSEBODY 
    326 //<html lang="ja"> 
    327 //<head> 
    328 //<body> 
    329 //this is testplus <br /> 
    330 //test!test! 
    331 //</body> 
    332 //</html> 
    333 //RESPONSEBODY; 
     329        $addResponseBody = '<html lang="ja">'. 
     330                           '<head>'. 
     331                           '<body>'. 
     332                           'this is testplus!!!!!<br />'. 
     333                           '</body>'. 
     334                           '</html>'; 
    334335        } 
    335336