From 2eeaaf92d18d81751c5a52dcc7c1dbdfbcdfc28c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sat, 9 Sep 2006 14:03:20 +0000 Subject: [PATCH] - add pipelining support to HttpRequestPool (libcurl >= 7.16.0) --- config9.m4 | 4 ++++ http_requestpool_object.c | 29 +++++++++++++++++++++++++++++ package2.xml | 13 ++++--------- php_http.h | 2 +- php_http_requestpool_object.h | 1 + 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/config9.m4 b/config9.m4 index 55397a7..1fcb91d 100644 --- a/config9.m4 +++ b/config9.m4 @@ -238,6 +238,10 @@ dnl ---- [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ], [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR] ) + PHP_CHECK_LIBRARY(curl, curl_multi_setopt, + [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ], + [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR] + ) fi dnl ---- diff --git a/http_requestpool_object.c b/http_requestpool_object.c index 69c3f96..ff8f75d 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -67,6 +67,10 @@ HTTP_EMPTY_ARGS(count); HTTP_EMPTY_ARGS(getAttachedRequests); HTTP_EMPTY_ARGS(getFinishedRequests); +HTTP_BEGIN_ARGS(enablePipelining, 0) + HTTP_ARG_VAL(enable, 0) +HTTP_END_ARGS; + zend_class_entry *http_requestpool_object_ce; zend_function_entry http_requestpool_object_fe[] = { HTTP_REQPOOL_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) @@ -91,6 +95,8 @@ zend_function_entry http_requestpool_object_fe[] = { HTTP_REQPOOL_ME(getAttachedRequests, ZEND_ACC_PUBLIC) HTTP_REQPOOL_ME(getFinishedRequests, ZEND_ACC_PUBLIC) + + HTTP_REQPOOL_ME(enablePipelining, ZEND_ACC_PUBLIC) EMPTY_FUNCTION_ENTRY }; @@ -517,6 +523,29 @@ PHP_METHOD(HttpRequestPool, getFinishedRequests) } /* }}} */ +/* {{{ proto bool HttpRequest::enablePiplelinig([bool enable = true]) + * + * Enables pipelining support for all attached requests if support in libcurl is given. + * + * Returns TRUE on success, or FALSE on failure. + */ +PHP_METHOD(HttpRequestPool, enablePipelining) +{ + zend_bool enable = 1; + getObject(http_requestpool_object, obj); + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &enable)) { + RETURN_FALSE; + } +#if defined(HAVE_CURL_MULTI_SETOPT) && HTTP_CURL_VERSION(7,16,0) + if (CURLM_OK == curl_multi_setopt(obj->pool.ch, CURLMOPT_PIPELINING, (long) enable)) { + RETURN_TRUE; + } +#endif + RETURN_FALSE; +} +/* }}} */ + #endif /* ZEND_ENGINE_2 && HTTP_HAVE_CURL */ /* diff --git a/package2.xml b/package2.xml index 4fe58aa..15cfea5 100644 --- a/package2.xml +++ b/package2.xml @@ -28,10 +28,10 @@ support. Parallel requests are available for PHP 5 and greater. mike@php.net yes - 2006-08-26 + 2006-09-00 - 1.2.1 - 1.2.0 + 1.3.0dev + 1.3.0 stable @@ -39,12 +39,7 @@ support. Parallel requests are available for PHP 5 and greater. BSD, revised = 7.16.0) ]]> diff --git a/php_http.h b/php_http.h index 66ecbcc..7b922a7 100644 --- a/php_http.h +++ b/php_http.h @@ -15,7 +15,7 @@ #ifndef PHP_EXT_HTTP_H #define PHP_EXT_HTTP_H -#define PHP_EXT_HTTP_VERSION "1.2.1" +#define PHP_EXT_HTTP_VERSION "1.3.0dev" #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/php_http_requestpool_object.h b/php_http_requestpool_object.h index b0ab065..7c7f694 100644 --- a/php_http_requestpool_object.h +++ b/php_http_requestpool_object.h @@ -51,6 +51,7 @@ PHP_METHOD(HttpRequestPool, rewind); PHP_METHOD(HttpRequestPool, count); PHP_METHOD(HttpRequestPool, getAttachedRequests); PHP_METHOD(HttpRequestPool, getFinishedRequests); +PHP_METHOD(HttpRequestPool, enablePipelining); #endif #endif -- 2.30.2