From a2a03258160b8dea5525a82c3251e0cbff4a3132 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 26 Aug 2005 09:52:50 +0000 Subject: [PATCH] - made low-lewel request pool object api more intuitive --- http_requestpool_object.c | 34 +++++++++++----------------------- package.xml | 4 +++- php_http_requestpool_object.h | 3 +-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/http_requestpool_object.c b/http_requestpool_object.c index e01e26d..b255e25 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -58,9 +58,8 @@ HTTP_BEGIN_ARGS(detach, 1) HTTP_END_ARGS; HTTP_EMPTY_ARGS(send, 0); -HTTP_EMPTY_ARGS(socketSend, 0); +HTTP_EMPTY_ARGS(socketPerform, 0); HTTP_EMPTY_ARGS(socketSelect, 0); -HTTP_EMPTY_ARGS(socketRead, 0); HTTP_EMPTY_ARGS(valid, 0); HTTP_EMPTY_ARGS(current, 1); @@ -80,9 +79,8 @@ zend_function_entry http_requestpool_object_fe[] = { HTTP_REQPOOL_ME(send, ZEND_ACC_PUBLIC) HTTP_REQPOOL_ME(reset, ZEND_ACC_PUBLIC) - HTTP_REQPOOL_ME(socketSend, ZEND_ACC_PROTECTED) + HTTP_REQPOOL_ME(socketPerform, ZEND_ACC_PROTECTED) HTTP_REQPOOL_ME(socketSelect, ZEND_ACC_PROTECTED) - HTTP_REQPOOL_ME(socketRead, ZEND_ACC_PROTECTED) /* implements Interator */ HTTP_REQPOOL_ME(valid, ZEND_ACC_PUBLIC) @@ -279,29 +277,33 @@ PHP_METHOD(HttpRequestPool, send) * Usage: *
  * socketSend()) {
+ *     while ($pool->socketPerform()) {
  *         do_something_else();
  *         if (!$pool->socketSelect()) {
  *             die('Socket error');
  *         }
  *     }
- *     $pool->socketRead();
  * ?>
  * 
*/ -PHP_METHOD(HttpRequestPool, socketSend) +PHP_METHOD(HttpRequestPool, socketPerform) { getObject(http_requestpool_object, obj); NO_ARGS; - RETURN_BOOL(0 < http_request_pool_perform(&obj->pool)); + if (0 < http_request_pool_perform(&obj->pool)) { + RETURN_TRUE; + } else { + zend_llist_apply(&obj->pool.handles, (llist_apply_func_t) http_request_pool_responsehandler TSRMLS_CC); + RETURN_FALSE; + } } /* }}} */ /* {{{ proto protected bool HttpRequestPool::socketSelect() * - * See HttpRequestPool::socketSend(). + * See HttpRequestPool::socketPerform(). */ PHP_METHOD(HttpRequestPool, socketSelect) { @@ -313,20 +315,6 @@ PHP_METHOD(HttpRequestPool, socketSelect) } /* }}} */ -/* {{{ 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); -} -/* }}} */ - /* implements Iterator */ /* {{{ proto bool HttpRequestPool::valid() diff --git a/package.xml b/package.xml index 7050c4d..7a033e1 100644 --- a/package.xml +++ b/package.xml @@ -1,6 +1,6 @@ - + pecl_http Extended HTTP support @@ -42,11 +42,13 @@ + Added constants HttpMessage::NONE, Http_Message::REQUEST, HttpMessage::RESPONSE + Added Content-Length header if HttpResponse sends full plain entity + Added ZendEngine workaround for internal class' static properties (HttpResponse) ++ Added HttpRequestPool::socketPerform() - Removed http_split_response() - Removed AuthBasic hooks - Removed HttpResponse::sendHeader(), HttpResponse::sendStatus() - Removed HttpRequest::unset*() methods, now handled through set*() with empty parameter +- Removed HttpRequestPool::socketRead(), HttpRequestPool::socketSend() * Fixed initialization and cleanup of module globals * Fixed builds and tests without libcurl diff --git a/php_http_requestpool_object.h b/php_http_requestpool_object.h index d3954f8..24c40e0 100644 --- a/php_http_requestpool_object.h +++ b/php_http_requestpool_object.h @@ -52,9 +52,8 @@ PHP_METHOD(HttpRequestPool, attach); PHP_METHOD(HttpRequestPool, detach); PHP_METHOD(HttpRequestPool, send); PHP_METHOD(HttpRequestPool, reset); -PHP_METHOD(HttpRequestPool, socketSend); +PHP_METHOD(HttpRequestPool, socketPerform); PHP_METHOD(HttpRequestPool, socketSelect); -PHP_METHOD(HttpRequestPool, socketRead); PHP_METHOD(HttpRequestPool, valid); PHP_METHOD(HttpRequestPool, current); PHP_METHOD(HttpRequestPool, key); -- 2.30.2