- added HttpException::__toString() which takes care about any inner exceptions
authorMichael Wallner <mike@php.net>
Thu, 24 Aug 2006 14:41:45 +0000 (14:41 +0000)
committerMichael Wallner <mike@php.net>
Thu, 24 Aug 2006 14:41:45 +0000 (14:41 +0000)
KnownIssues.txt
http_exception_object.c
http_request_pool_api.c
package.xml
package2.xml
php_http.h
php_http_exception_object.h
tests/HttpRequestPool_005.phpt

index 19c593c28024a8b9009ea4593eaea08323fb57d7..fac8a3cf98c27fca67b7348c522ddccd6e98e674 100644 (file)
@@ -20,3 +20,5 @@ not work as expected in a PHP version lower than 5.1.3.
 Internals:
        -       our http_urlencode_hash() does not differentiate between prefixes
                for numeric or string keys.
 Internals:
        -       our http_urlencode_hash() does not differentiate between prefixes
                for numeric or string keys.
+       -       detaching a request from a pool in its progress callback causes
+               all sorts of memory errors
index 9074005aed96ad137d83b5ece270f86676c3ef46..4562922bad76cd273187fba6a14b9b6f0b494e61 100644 (file)
@@ -16,6 +16,7 @@
 
 #ifdef ZEND_ENGINE_2
 
 
 #ifdef ZEND_ENGINE_2
 
+#include "zend_interfaces.h"
 #include "php_http_exception_object.h"
 
 zend_class_entry *http_exception_object_ce;
 #include "php_http_exception_object.h"
 
 zend_class_entry *http_exception_object_ce;
@@ -33,9 +34,21 @@ zend_class_entry *HTTP_EX_CE(response);
 zend_class_entry *HTTP_EX_CE(url);
 zend_class_entry *HTTP_EX_CE(querystring);
 
 zend_class_entry *HTTP_EX_CE(url);
 zend_class_entry *HTTP_EX_CE(querystring);
 
+#define HTTP_EMPTY_ARGS(method)                                HTTP_EMPTY_ARGS_EX(HttpException, method, 0)
+#define HTTP_EXCEPTION_ME(method, visibility)  PHP_ME(HttpException, method, HTTP_ARGS(HttpException, method), visibility)
+
+HTTP_EMPTY_ARGS(__toString);
+
+#define OBJ_PROP_CE http_deflatestream_object_ce
+zend_function_entry http_exception_object_fe[] = {
+       HTTP_EXCEPTION_ME(__toString, ZEND_ACC_PUBLIC)
+       
+       EMPTY_FUNCTION_ENTRY
+};
+
 PHP_MINIT_FUNCTION(http_exception_object)
 {
 PHP_MINIT_FUNCTION(http_exception_object)
 {
-       HTTP_REGISTER_EXCEPTION(HttpException, http_exception_object_ce, ZEND_EXCEPTION_GET_DEFAULT());
+       HTTP_REGISTER_CLASS(HttpException, http_exception_object, ZEND_EXCEPTION_GET_DEFAULT(), 0);
        
        zend_declare_property_null(HTTP_EX_DEF_CE, "innerException", lenof("innerException"), ZEND_ACC_PUBLIC TSRMLS_CC);
        
        
        zend_declare_property_null(HTTP_EX_DEF_CE, "innerException", lenof("innerException"), ZEND_ACC_PUBLIC TSRMLS_CC);
        
@@ -98,6 +111,44 @@ zend_class_entry *_http_exception_get_for_code(long code)
        return ex;
 }
 
        return ex;
 }
 
+PHP_METHOD(HttpException, __toString)
+{
+       phpstr full_str;
+       zend_class_entry *ce;
+       zval *zobj = getThis(), *retval = NULL, *m, *f, *l;
+       
+       phpstr_init(&full_str);
+       
+       do {
+               ce = Z_OBJCE_P(zobj);
+               
+               if (zobj != getThis()) {
+                       phpstr_appends(&full_str, " inner ");
+               }
+               
+               m = zend_read_property(ce, zobj, "message", lenof("message"), 0 TSRMLS_CC);
+               f = zend_read_property(ce, zobj, "file", lenof("file"), 0 TSRMLS_CC);
+               l = zend_read_property(ce, zobj, "line", lenof("line"), 0 TSRMLS_CC);
+               
+               if (m && f && l && Z_TYPE_P(m) == IS_STRING && Z_TYPE_P(f) == IS_STRING && Z_TYPE_P(l) == IS_LONG) {
+                       phpstr_appendf(&full_str, "exception '%.*s' with message '%.*s' in %.*s:%ld" PHP_EOL,
+                               ce->name_length, ce->name, Z_STRLEN_P(m), Z_STRVAL_P(m), Z_STRLEN_P(f), Z_STRVAL_P(f), Z_LVAL_P(l)
+                       );
+               } else {
+                       break;
+               }
+               
+               zobj = zend_read_property(ce, zobj, "innerException", lenof("innerException"), 0 TSRMLS_CC);
+       } while (Z_TYPE_P(zobj) == IS_OBJECT);
+       
+       if (zend_call_method_with_0_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "gettraceasstring", &retval) && Z_TYPE_P(retval) == IS_STRING) {
+               phpstr_appends(&full_str, "Stack trace:" PHP_EOL);
+               phpstr_append(&full_str, Z_STRVAL_P(retval), Z_STRLEN_P(retval));
+               zval_ptr_dtor(&retval);
+       }
+       
+       RETURN_PHPSTR_VAL(&full_str);
+}
 #endif
 
 /*
 #endif
 
 /*
index e93a078c0b7b1ac6cccc8dcc054b1888e253c17d..ae125259302939a74a3882147f23b185bd0ceaa1 100644 (file)
@@ -216,7 +216,8 @@ PHP_HTTP_API STATUS _http_request_pool_send(http_request_pool *pool TSRMLS_DC)
        while (http_request_pool_perform(pool, 0)) {
                if (SUCCESS != http_request_pool_select(pool)) {
 #ifdef PHP_WIN32
        while (http_request_pool_perform(pool, 0)) {
                if (SUCCESS != http_request_pool_select(pool)) {
 #ifdef PHP_WIN32
-                       http_error(HE_WARNING, HTTP_E_SOCKET, WSAGetLastError());
+                       /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */
+                       http_error_ex(HE_WARNING, HTTP_E_SOCKET, "WinSock error: %d", WSAGetLastError());
 #else
                        http_error(HE_WARNING, HTTP_E_SOCKET, strerror(errno));
 #endif
 #else
                        http_error(HE_WARNING, HTTP_E_SOCKET, strerror(errno));
 #endif
index bd9a6a6b180775ae8a49d0ed599a495e8cbddacf..afc7bc793f086c240ea2cceb8a5ae42fc0d8841e 100644 (file)
@@ -23,14 +23,15 @@ support. Parallel requests are available for PHP 5 and greater.
   </maintainer>
   </maintainers>
  <release>
   </maintainer>
   </maintainers>
  <release>
-  <version>1.2.0</version>
-  <date>2006-08-18</date>
+  <version>1.2.1</version>
+  <date>2006-08-24</date>
   <license>BSD, revised</license>
   <state>stable</state>
   <license>BSD, revised</license>
   <state>stable</state>
-  <notes>+ Improved response performance (HttpResponse, http_send API)
-* Fixed http_parse_cookie() allowed_extras and flags parameters
-* Added http_build_cookie() function
-* Fixed configuration with shared dependencies
+  <notes>+ Added HttpException::__toString() which takes care about any inner exceptions
+* Fixed issues with inheritance and cloning of HttpDeflateStream, HttpInflateStream and HttpMessage
+  (Extending classes lose default properties on instantiation; Complex members ignored during cloning)
+* Fixed suppression of nested exceptions in e.g. HttpRequestPool::send() (fixes bug #8535)
+* Fixed crash on detaching requests from pool in request event callbacks
   </notes>
   <deps>
    <dep type="php" rel="ge" version="4.3"/>
   </notes>
   <deps>
    <dep type="php" rel="ge" version="4.3"/>
@@ -114,6 +115,7 @@ support. Parallel requests are available for PHP 5 and greater.
     <file role="test" name="HttpRequestPool_003.phpt"/>
     <file role="test" name="HttpRequestPool_004.phpt"/>
     <file role="test" name="HttpRequestPool_005.phpt"/>
     <file role="test" name="HttpRequestPool_003.phpt"/>
     <file role="test" name="HttpRequestPool_004.phpt"/>
     <file role="test" name="HttpRequestPool_005.phpt"/>
+    <file role="test" name="HttpRequestPool_006.phpt"/>
     <file role="test" name="HttpRequest_001.phpt"/>
     <file role="test" name="HttpRequest_002.phpt"/>
     <file role="test" name="HttpRequest_003.phpt"/>
     <file role="test" name="HttpRequest_001.phpt"/>
     <file role="test" name="HttpRequest_002.phpt"/>
     <file role="test" name="HttpRequest_003.phpt"/>
index 406cadade166e74eadbfd4a4d008ee8b3950c3e3..fe7c74995af0962c1f6eef8613c5fb3e45cbe7b7 100644 (file)
@@ -28,7 +28,7 @@ support. Parallel requests are available for PHP 5 and greater.
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2006-08-00</date>
+ <date>2006-08-24</date>
  <version>
   <release>1.2.1</release>
   <api>1.2.0</api>
  <version>
   <release>1.2.1</release>
   <api>1.2.0</api>
@@ -39,9 +39,10 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
++ Added HttpException::__toString() which takes care about any inner exceptions
 * Fixed issues with inheritance and cloning of HttpDeflateStream, HttpInflateStream and HttpMessage
   (Extending classes lose default properties on instantiation; Complex members ignored during cloning)
 * Fixed issues with inheritance and cloning of HttpDeflateStream, HttpInflateStream and HttpMessage
   (Extending classes lose default properties on instantiation; Complex members ignored during cloning)
-* Fixed suppression of nested exceptions in e.g. HttpRequestPool::send()
+* Fixed suppression of nested exceptions in e.g. HttpRequestPool::send() (fixes bug #8535)
 * Fixed crash on detaching requests from pool in request event callbacks
 ]]></notes>
  <contents>
 * Fixed crash on detaching requests from pool in request event callbacks
 ]]></notes>
  <contents>
index 5ba031185fb7511817b1fb5840145388cea9e21e..66ecbcc3e02d81288542296eb4a515d70eb11b93 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_EXT_HTTP_VERSION "1.2.1dev"
+#define PHP_EXT_HTTP_VERSION "1.2.1"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
index 9cf42cb83b22b9e3db6d98b70ee01333c732a259..9afaaf717aac44e65d4a55e11561fdf82e25c576 100644 (file)
@@ -44,6 +44,8 @@ extern zend_class_entry *_http_exception_get_default();
 #define http_exception_get_for_code(c) _http_exception_get_for_code(c)
 extern zend_class_entry *_http_exception_get_for_code(long code);
 
 #define http_exception_get_for_code(c) _http_exception_get_for_code(c)
 extern zend_class_entry *_http_exception_get_for_code(long code);
 
+PHP_METHOD(HttpException, __toString);
+
 #endif
 #endif
 
 #endif
 #endif
 
index 80a6c648d7ace68a2e5a335cc4867d484758ea02..a36299a1572af9b991c22f6da5bddd44d98195e0 100644 (file)
@@ -32,11 +32,11 @@ echo "Done\n";
 ?>
 --EXPECTF--
 %sTEST
 ?>
 --EXPECTF--
 %sTEST
-HttpRequestPoolException: Exception caused by inner exception(s)
+HttpRequestPoolException: Exception caused by inner exception(s)
        HttpInvalidParamException: Empty or too short HTTP message: ''
                HttpRequestException: couldn't resolve host name; Couldn't resolve host '_____' (http://_____/)
 int(3)
        HttpInvalidParamException: Empty or too short HTTP message: ''
                HttpRequestException: couldn't resolve host name; Couldn't resolve host '_____' (http://_____/)
 int(3)
-HttpRequestPoolException: Exception caused by inner exception(s)
+HttpRequestPoolException: Exception caused by inner exception(s)
        HttpInvalidParamException: Empty or too short HTTP message: ''
                HttpRequestException: couldn't resolve host name; Couldn't resolve host '_____' (http://_____/)
                        HttpInvalidParamException: Empty or too short HTTP message: ''
        HttpInvalidParamException: Empty or too short HTTP message: ''
                HttpRequestException: couldn't resolve host name; Couldn't resolve host '_____' (http://_____/)
                        HttpInvalidParamException: Empty or too short HTTP message: ''