+static void handle_debug(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, unsigned type, const char *data, size_t size)
+{
+ zval ztype, zdata, zreq, zclient;
+ php_http_client_object_t *client_obj = arg;
+ zend_error_handling zeh;
+
+ ZVAL_OBJECT(&zclient, &client_obj->zo, 1);
+ ZVAL_OBJECT(&zreq, &((php_http_message_object_t *) e->opaque)->zo, 1);
+ ZVAL_LONG(&ztype, type);
+ ZVAL_STRINGL(&zdata, data, size);
+
+ zend_replace_error_handling(EH_NORMAL, NULL, &zeh);
+ if (SUCCESS == zend_fcall_info_argn(&client_obj->debug.fci, 4, &zclient, &zreq, &ztype, &zdata)) {
+ ++client->callback.depth;
+ zend_fcall_info_call(&client_obj->debug.fci, &client_obj->debug.fcc, NULL, NULL);
+ --client->callback.depth;
+ zend_fcall_info_args_clear(&client_obj->debug.fci, 0);
+ }
+ zend_restore_error_handling(&zeh);
+
+ zval_ptr_dtor(&zclient);
+ zval_ptr_dtor(&zreq);
+ zval_ptr_dtor(&ztype);
+ zval_ptr_dtor(&zdata);
+}
+