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
#ifdef ZEND_ENGINE_2
+#include "zend_interfaces.h"
#include "php_http_exception_object.h"
zend_class_entry *http_exception_object_ce;
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)
{
- 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);
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
/*
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
</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>
- <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"/>
<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"/>
<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>
</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 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>
#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"
#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
?>
--EXPECTF--
%sTEST
-HttpRequestPoolException: Exception caused by inner exception(s)
+HttpRequestPoolException: Exception caused by 2 inner exception(s)
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 4 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: ''