X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=http_methods.c;h=d71c2caa6d4d7a5f4756ac6baabea975c6eabba0;hb=92d91587592727bbf0369e6eae8eba157063274d;hp=f844c055ba06f3606be5a5281cfba399f771877b;hpb=559c156f3d0aeffe2c920d9275f47cfcdfc40bdf;p=m6w6%2Fext-http diff --git a/http_methods.c b/http_methods.c index f844c05..d71c2ca 100644 --- a/http_methods.c +++ b/http_methods.c @@ -2069,12 +2069,10 @@ PHP_METHOD(HttpRequest, getResponseMessage) getObject(http_request_object, obj); message = GET_PROP(obj, responseMessage); - Z_TYPE_P(return_value) = IS_OBJECT; - return_value->is_ref = 1; - return_value->value.obj = message->value.obj; - zval_add_ref(&return_value); + RETVAL_OBJECT(message); } } +/* }}} */ /* {{{ proto bool HttpRequest::send() * @@ -2142,13 +2140,46 @@ PHP_METHOD(HttpRequest, send) /* {{{ HttpRequestPool */ -/* {{{ proto void HttpRequestPool::__construct() +/* {{{ proto void HttpRequestPool::__construct([HttpRequest request[, ...]]) + * + * Instantiate a new HttpRequestPool object. An HttpRequestPool is + * able to send several HttpRequests in parallel. * - * Instantiate a new HttpRequestPool object. + * 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); } /* }}} */ @@ -2162,7 +2193,7 @@ PHP_METHOD(HttpRequestPool, __destruct) NO_ARGS; - //http_request_pool_detach_all(&obj->pool); + http_request_pool_detach_all(&obj->pool); } /* }}} */ @@ -2300,3 +2331,4 @@ PHP_METHOD(HttpRequestPool, socketRead) * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ +