X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_methods.c;h=a8f5d9489da81df92d4ce113213badc2074d1e93;hp=cf8f25dd371807f818f86f264b739034694c4aeb;hb=6bd8a9818c329bb7526f3db8b8d8ef36a95f303f;hpb=76a1064dde808801f4988df89521a323661742aa diff --git a/http_methods.c b/http_methods.c index cf8f25d..a8f5d94 100644 --- a/http_methods.c +++ b/http_methods.c @@ -2119,7 +2119,7 @@ PHP_METHOD(HttpRequest, send) SET_EH_THROW_HTTP(); - if (obj->attached) { + if (obj->pool) { http_error(E_WARNING, HTTP_E_CURL, "You cannot call HttpRequest::send() while attached to an HttpRequestPool"); RETURN_FALSE; } @@ -2143,7 +2143,7 @@ PHP_METHOD(HttpRequest, send) /* {{{ HttpRequestPool */ -/* {{{ proto void HttpRequestPool::__construct(void) +/* {{{ proto void HttpRequestPool::__construct() * * Instantiate a new HttpRequestPool object. */ @@ -2153,6 +2153,33 @@ PHP_METHOD(HttpRequestPool, __construct) } /* }}} */ +/* {{{ proto void HttpRequestPool::__destruct() + * + * Clean up HttpRequestPool object. + */ +PHP_METHOD(HttpRequestPool, __destruct) +{ + getObject(http_requestpool_object, obj); + + NO_ARGS; + + http_request_pool_detach_all(&obj->pool); +} +/* }}} */ + +/* {{{ proto void HttpRequestPool::reset() + * + * Detach all attached HttpRequest objects. + */ +PHP_METHOD(HttpRequestPool, reset) +{ + getObject(http_requestpool_object, obj); + + NO_ARGS; + + http_request_pool_detach_all(&obj->pool); +} + /* {{{ proto bool HttpRequestPool::attach(HttpRequest request) * * Attach an HttpRequest object to this HttpRequestPool. @@ -2206,6 +2233,58 @@ PHP_METHOD(HttpRequestPool, send) } /* }}} */ +/* {{{ proto protected bool HttpRequestPool::socketSend() + * + * Usage: + *
+ *	socketSend()) {
+ *			do_something_else();
+ *			if (!$pool->socketSelect()) {
+ *				die('Socket error');
+ *			}
+ *		}
+ *		$pool->socketRead();
+ *	?>
+ * 
+ */ +PHP_METHOD(HttpRequestPool, socketSend) +{ + getObject(http_requestpool_object, obj); + + NO_ARGS; + + RETURN_BOOL(0 < http_request_pool_perform(&obj->pool)); +} +/* }}} */ + +/* {{{ proto protected bool HttpRequestPool::socketSelect() + * + * See HttpRequestPool::socketSend(). + */ +PHP_METHOD(HttpRequestPool, socketSelect) +{ + getObject(http_requestpool_object, obj); + + NO_ARGS; + + RETURN_SUCCESS(http_request_pool_select(&obj->pool)); +} +/* }}} */ + +/* {{{ proto protected void HttpRequestPool::socketRead() + * + * See HttpRequestPool::socketSend(). + */ +PHP_METHOD(HttpRequestPool, socketRead) +{ + getObject(http_requestpool_object, obj); + + NO_ARGS; + + zend_llist_apply(&obj->pool.handles, (llist_apply_func_t) http_request_pool_responsehandler TSRMLS_CC); +} + /* }}} */ /* }}} */