X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_methods.c;h=1e454d83a3477dc884a98a07cb38bb0c48f6bfa2;hb=208e6a34f0d48978279a2e80d336e19dca936486;hp=cf1fb9e0ebd96c812e06eb5ebe84ab6576c302e0;hpb=ab29a31d9129a377cdd664de08cb2bf86a72be1b;p=m6w6%2Fext-http diff --git a/http_methods.c b/http_methods.c index cf1fb9e..1e454d8 100644 --- a/http_methods.c +++ b/http_methods.c @@ -27,6 +27,7 @@ #include "php_http_api.h" #include "php_http_cache_api.h" #include "php_http_request_api.h" +#include "php_http_request_pool_api.h" #include "php_http_date_api.h" #include "php_http_headers_api.h" #include "php_http_message_api.h" @@ -2141,13 +2142,46 @@ PHP_METHOD(HttpRequest, send) /* {{{ HttpRequestPool */ -/* {{{ proto void HttpRequestPool::__construct() +/* {{{ proto void HttpRequestPool::__construct([HttpRequest request[, ...]]) * - * Instantiate a new HttpRequestPool object. + * Instantiate a new HttpRequestPool object. An HttpRequestPool is + * able to send several HttpRequests in parallel. + * + * Example: + *
+ * attach($req[$url]);
+ *     }
+ *     $pool->send();
+ *     foreach ($urls as $url) {
+ *         printf("%s (%s) is %s\n", 
+ *             $url, $req[$url]->getResponseInfo('effective_url'), 
+ *             $r->getResponseCode() == 200 ? 'alive' : 'not alive'
+ *         );
+ *     }
+ * ?>
+ * 
*/ PHP_METHOD(HttpRequestPool, __construct) { - NO_ARGS; + int argc = ZEND_NUM_ARGS(); + zval ***argv = safe_emalloc(argc, sizeof(zval *), 0); + getObject(http_requestpool_object, obj); + + 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])); + } + } + } + efree(argv); } /* }}} */