r4106 - in branches/0.10: main/Utils/Http test/main

From: <aelAT@ATshadanakar.org>
Date: Mon, 20 Aug 2007 15:59:31 +0400 (MSD)

Author: ael
Date: 2007-08-20 15:59:31 +0400 (Mon, 20 Aug 2007)
New Revision: 4106

Modified:
   branches/0.10/main/Utils/Http/CurlHttpClient.class.php
   branches/0.10/test/main/CryptoTest.class.php
Log:
CryptoTest: cosmetics
CurlHttpClient - one handle per request to avoid segfaults

Modified: branches/0.10/main/Utils/Http/CurlHttpClient.class.php
===================================================================
--- branches/0.10/main/Utils/Http/CurlHttpClient.class.php 2007-08-20 08:42:45 UTC (rev 4105)
+++ branches/0.10/main/Utils/Http/CurlHttpClient.class.php 2007-08-20 11:59:31 UTC (rev 4106)
@@ -18,11 +18,6 @@
                 private $maxRedirects = null;
                 private $maxFileSize = null;
                 
- public function __construct()
- {
- $this->handle = curl_init();
- }
-
                 /**
                  * @return CurlHttpClient
                  */
@@ -31,11 +26,6 @@
                         return new self;
                 }
                 
- public function __destruct()
- {
- curl_close($this->handle);
- }
-
                 /**
                  * @return CurlHttpClient
                  * @param $timeout in seconds
@@ -109,6 +99,8 @@
                                 )
                         );
                         
+ $handle = curl_init();
+
                         $response = CurlHttpResponse::create()->
                                 setMaxFileSize($this->maxFileSize);
                         
@@ -135,26 +127,28 @@
                                 $options[CURLOPT_POSTFIELDS] = $request->getPost();
                         }
                         
- curl_setopt_array($this->handle, $options);
-
- if (curl_exec($this->handle) === false) {
+ curl_setopt_array($handle, $options);
+
+ if (curl_exec($handle) === false) {
                                 throw new NetworkException(
                                         'curl error, code: '
- .curl_errno($this->handle)
+ .curl_errno($handle)
                                         .' description: '
- .curl_error($this->handle)
+ .curl_error($handle)
                                 );
                         }
                         
                         $response->setStatus(
                                 new HttpStatus(
                                         curl_getinfo(
- $this->handle,
+ $handle,
                                                 CURLINFO_HTTP_CODE
                                         )
                                 )
                         );
                         
+ curl_close($handle);
+
                         return $response;
                 }
         }

Modified: branches/0.10/test/main/CryptoTest.class.php
===================================================================
--- branches/0.10/test/main/CryptoTest.class.php 2007-08-20 08:42:45 UTC (rev 4105)
+++ branches/0.10/test/main/CryptoTest.class.php 2007-08-20 11:59:31 UTC (rev 4106)
@@ -20,13 +20,13 @@
                         $parameters = DiffieHellmanParameters::create(
                                 $factory->makeNumber(2),
                                 $factory->makeNumber(
- '155172898181473697471232257763715539915724801'.
- '966915404479707795314057629378541917580651227423'.
- '698188993727816152646631438561595825688188889951'.
- '272158842675419950341258706556549803580104870537'.
- '681476726513255747040765857479291291572334510643'.
- '245094715007229621094194349783925984760375594985'.
- '848253359305585439638443'
+ '155172898181473697471232257763715539915724801'
+ .'966915404479707795314057629378541917580651227423'
+ .'698188993727816152646631438561595825688188889951'
+ .'272158842675419950341258706556549803580104870537'
+ .'681476726513255747040765857479291291572334510643'
+ .'245094715007229621094194349783925984760375594985'
+ .'848253359305585439638443'
                                 )
                         );
                         
Received on Mon Aug 20 2007 - 15:59:31 MSD

This archive was generated by hypermail 2.2.0 : Sun Oct 28 2007 - 00:23:26 MSD