X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_requestpool_object.c;h=60c07486f52bf30adbba6e26e07749983a3b0adf;hp=0bb585974c64e8ba0e5f462659f49e2fa9859bb5;hb=05c863a6faa9a3ddd83ac1bdf62edbfc7a6ccf4f;hpb=2b37ee95b452cff42c17bf3d12d0ee1ebd08ba84 diff --git a/http_requestpool_object.c b/http_requestpool_object.c index 0bb5859..60c0748 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -12,37 +12,34 @@ /* $Id$ */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "php.h" + +#define HTTP_WANT_CURL +#include "php_http.h" #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL) -#include "php_http_std_defs.h" +#include "zend_interfaces.h" + #include "php_http_api.h" -#include "php_http_requestpool_object.h" -#include "php_http_request_pool_api.h" -#include "php_http_request_object.h" #include "php_http_exception_object.h" +#include "php_http_request_api.h" +#include "php_http_request_object.h" +#include "php_http_request_pool_api.h" +#include "php_http_requestpool_object.h" -#include "zend_interfaces.h" -#ifdef HAVE_SPL -# include "ext/spl/spl_array.h" -# include "ext/spl/spl_iterators.h" -#endif - -#ifdef PHP_WIN32 -# include +#if defined(HAVE_SPL) && !defined(WONKY) +/* SPL doesn't install its headers */ +extern PHPAPI zend_class_entry *spl_ce_Countable; #endif -#include #define HTTP_BEGIN_ARGS(method, req_args) HTTP_BEGIN_ARGS_EX(HttpRequestPool, method, 0, req_args) #define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpRequestPool, method, ret_ref) #define HTTP_REQPOOL_ME(method, visibility) PHP_ME(HttpRequestPool, method, HTTP_ARGS(HttpRequestPool, method), visibility) -HTTP_BEGIN_ARGS_AR(HttpRequestPool, __construct, 0, 0) +HTTP_BEGIN_ARGS(__construct, 0) HTTP_ARG_OBJ(HttpRequest, request0, 0) HTTP_ARG_OBJ(HttpRequest, request1, 0) HTTP_ARG_OBJ(HttpRequest, requestN, 0) @@ -89,7 +86,7 @@ zend_function_entry http_requestpool_object_fe[] = { HTTP_REQPOOL_ME(socketPerform, ZEND_ACC_PROTECTED) HTTP_REQPOOL_ME(socketSelect, ZEND_ACC_PROTECTED) - /* implements Interator */ + /* implements Iterator */ HTTP_REQPOOL_ME(valid, ZEND_ACC_PUBLIC) HTTP_REQPOOL_ME(current, ZEND_ACC_PUBLIC) HTTP_REQPOOL_ME(key, ZEND_ACC_PUBLIC) @@ -109,8 +106,8 @@ static zend_object_handlers http_requestpool_object_handlers; PHP_MINIT_FUNCTION(http_requestpool_object) { HTTP_REGISTER_CLASS_EX(HttpRequestPool, http_requestpool_object, NULL, 0); -#ifdef HAVE_SPL - zend_class_implements(http_requestpool_object_ce TSRMLS_CC, 2, spl_ce_Countable, spl_ce_Iterator); +#if defined(HAVE_SPL) && !defined(WONKY) + zend_class_implements(http_requestpool_object_ce TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator); #else zend_class_implements(http_requestpool_object_ce TSRMLS_CC, 1, zend_ce_iterator); #endif @@ -173,12 +170,12 @@ static void _http_requestpool_object_llist2array(zval **req, zval *array TSRMLS_ * able to send several HttpRequests in parallel. * * WARNING: Don't attach/detach HttpRequest objects to the HttpRequestPool - * object while you're using the implemented Interator interface. + * object while you're using the implemented Iterator interface. * * Accepts virtual infinite optional parameters each referencing an * HttpRequest object. * - * Throws HttpRequestException, HttpRequestPoolException, HttpInvalidParamException. + * Throws HttpRequestPoolException (HttpRequestException, HttpInvalidParamException). * * Example: *
@@ -208,16 +205,21 @@ PHP_METHOD(HttpRequestPool, __construct)
 	zval ***argv = safe_emalloc(argc, sizeof(zval *), 0);
 	getObject(http_requestpool_object, obj);
 
+	SET_EH_THROW_HTTP();
 	if (SUCCESS == zend_get_parameters_array_ex(argc, argv)) {
 		int i;
 
 		for (i = 0; i < argc; ++i) {
 			if (Z_TYPE_PP(argv[i]) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(argv[i]), http_request_object_ce TSRMLS_CC)) {
-				http_request_pool_attach(&obj->pool, *(argv[i]));
+				http_request_pool_try {
+					http_request_pool_attach(&obj->pool, *(argv[i]));
+				} http_request_pool_catch();
 			}
 		}
+		http_request_pool_final();
 	}
 	efree(argv);
+	SET_EH_NORMAL();
 }
 /* }}} */
 
@@ -314,8 +316,7 @@ PHP_METHOD(HttpRequestPool, detach)
  * 
  * Returns TRUE on success, or FALSE on failure.
  * 
- * Throws HttpSocketException, HttpRequestException, 
- * HttpRequestPoolException, HttpMalformedHeaderException.
+ * Throws HttpRequestPoolException (HttpSocketException, HttpRequestException, HttpMalformedHeaderException).
  */
 PHP_METHOD(HttpRequestPool, send)
 {