])
fi
+dnl ----
+dnl RAPHF
+dnl ----
+ HTTP_HAVE_PHP_EXT([raphf], [
+ AC_MSG_CHECKING([for php_raphf.h])
+ HTTP_EXT_RAPHF_INCDIR=
+ for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
+ if test -d $i; then
+ if test -f $i/php_raphf.h; then
+ HTTP_EXT_RAPHF_INCDIR=$i
+ break
+ elif test -f $i/ext/raphf/php_raphf.h; then
+ HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf
+ break
+ fi
+ fi
+ done
+ if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then
+ AC_MSG_FAILURE([not found])
+ else
+ AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR])
+ AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
+ PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR])
+ fi
+ ])
+
PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
[ --without-http-shared-deps HTTP: do not depend on extensions like hash
and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
php_http_object.c \
php_http_options.c \
php_http_params.c \
- php_http_persistent_handle.c \
php_http_property_proxy.c \
php_http_querystring.c \
- php_http_resource_factory.c \
php_http_strlist.c \
php_http_url.c \
php_http_version.c \
php_http_object.h \
php_http_options.h \
php_http_params.h \
- php_http_persistent_handle.h \
php_http_property_proxy.h \
php_http_querystring.h \
- php_http_resource_factory.h \
php_http_strlist.h \
php_http_url.h \
php_http_version.h \
PHP_MINFO_FUNCTION(http);
static zend_module_dep http_module_deps[] = {
+ ZEND_MOD_REQUIRED("raphf")
ZEND_MOD_REQUIRED("spl")
#ifdef PHP_HTTP_HAVE_HASH
ZEND_MOD_REQUIRED("hash")
PHP_INI_BEGIN()
PHP_HTTP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL, OnUpdateString, env.etag_mode)
- PHP_HTTP_INI_ENTRY("http.persistent_handle.limit", "-1", PHP_INI_SYSTEM, OnUpdateLong, persistent_handle.limit)
PHP_INI_END()
PHP_MINIT_FUNCTION(http)
if (0
|| SUCCESS != PHP_MINIT_CALL(http_object)
|| SUCCESS != PHP_MINIT_CALL(http_exception)
- || SUCCESS != PHP_MINIT_CALL(http_persistent_handle)
|| SUCCESS != PHP_MINIT_CALL(http_cookie)
|| SUCCESS != PHP_MINIT_CALL(http_encoding)
|| SUCCESS != PHP_MINIT_CALL(http_filter)
|| SUCCESS != PHP_MSHUTDOWN_CALL(http_curl_client)
|| SUCCESS != PHP_MSHUTDOWN_CALL(http_curl)
#endif
- || SUCCESS != PHP_MSHUTDOWN_CALL(http_persistent_handle)
|| SUCCESS != PHP_MSHUTDOWN_CALL(http_client_factory)
) {
return FAILURE;
php_http_buffer_reset(&buf);
php_http_registered_classes(&buf, ZEND_ACC_FINAL_CLASS);
php_info_print_table_row(2, "Final Classes", buf.data);
- php_http_buffer_reset(&buf);
+ php_http_buffer_dtor(&buf);
php_info_print_table_row(2, "Stream Filters", "http.chunked_encode, http.chunked_decode, http.inflate, http.deflate");
php_info_print_table_end();
- php_info_print_table_start();
- php_info_print_table_colspan_header(4, "Persistent Handles");
- php_info_print_table_header(4, "Provider", "Ident", "Used", "Free");
- {
- HashTable *ht;
- HashPosition pos1, pos2;
- php_http_array_hashkey_t provider = php_http_array_hashkey_init(0), ident = php_http_array_hashkey_init(0);
- zval **val, **sub, **zused, **zfree;
-
- if ((ht = php_http_persistent_handle_statall(NULL TSRMLS_CC)) && zend_hash_num_elements(ht)) {
- FOREACH_HASH_KEYVAL(pos1, ht, provider, val) {
- if (zend_hash_num_elements(Z_ARRVAL_PP(val))) {
- FOREACH_KEYVAL(pos2, *val, ident, sub) {
- if ( SUCCESS == zend_hash_find(Z_ARRVAL_PP(sub), ZEND_STRS("used"), (void *) &zused) &&
- SUCCESS == zend_hash_find(Z_ARRVAL_PP(sub), ZEND_STRS("free"), (void *) &zfree)) {
- zval *used = php_http_ztyp(IS_STRING, *zused);
- zval *free = php_http_ztyp(IS_STRING, *zfree);
- php_info_print_table_row(4, provider.str, ident.str, Z_STRVAL_P(used), Z_STRVAL_P(free));
- zval_ptr_dtor(&used);
- zval_ptr_dtor(&free);
- } else {
- php_info_print_table_row(4, provider.str, ident.str, "0", "0");
- }
- }
- } else {
- php_info_print_table_row(4, provider.str, "N/A", "0", "0");
- }
- }
- } else {
- php_info_print_table_row(4, "N/A", "N/A", "0", "0");
- }
- if (ht) {
- zend_hash_destroy(ht);
- FREE_HASHTABLE(ht);
- }
- }
- php_info_print_table_end();
-
- php_http_buffer_dtor(&buf);
DISPLAY_INI_ENTRIES();
}
#include <php.h>
#include <SAPI.h>
+#include <ext/raphf/php_raphf.h>
#include <ext/standard/php_string.h>
#include <ext/spl/spl_iterators.h>
#include <ext/date/php_date.h>
#include "php_http_buffer.h"
#include "php_http_strlist.h"
#include "php_http_misc.h"
-#include "php_http_resource_factory.h"
#include "php_http_options.h"
#include "php_http.h"
#include "php_http_negotiate.h"
#include "php_http_object.h"
#include "php_http_params.h"
-#include "php_http_persistent_handle.h"
#include "php_http_property_proxy.h"
#include "php_http_querystring.h"
#include "php_http_client_interface.h"
ZEND_BEGIN_MODULE_GLOBALS(php_http)
struct php_http_env_globals env;
- struct php_http_persistent_handle_globals persistent_handle;
#if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT
struct php_http_curl_globals curl;
#endif
#include <ext/spl/spl_observer.h>
#include <ext/standard/php_array.h>
-PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
+PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
{
php_http_client_t *free_h = NULL;
if (rf) {
h->rf = rf;
} else if (ops->rsrc) {
- h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
}
h->request.buffer = php_http_buffer_init(NULL);
h->request.parser = php_http_message_parser_init(NULL TSRMLS_CC);
h->ops->dtor(h);
}
- php_http_resource_factory_free(&h->rf);
+ php_resource_factory_free(&h->rf);
php_http_message_parser_free(&h->request.parser);
php_http_message_free(&h->request.message);
to->ops = from->ops;
if (from->rf) {
- php_http_resource_factory_addref(from->rf);
+ php_resource_factory_addref(from->rf);
to->rf = from->rf;
} else if (to->ops->rsrc){
- to->rf = php_http_resource_factory_init(NULL, to->ops->rsrc, to, NULL);
+ to->rf = php_resource_factory_init(NULL, to->ops->rsrc, to, NULL);
}
to->request.buffer = php_http_buffer_init(NULL);
typedef STATUS (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg);
typedef struct php_http_client_ops {
- php_http_resource_factory_ops_t *rsrc;
+ php_resource_factory_ops_t *rsrc;
php_http_client_init_func_t init;
php_http_client_copy_func_t copy;
php_http_client_dtor_func_t dtor;
typedef struct php_http_client {
void *ctx;
- php_http_resource_factory_t *rf;
+ php_resource_factory_t *rf;
php_http_client_ops_t *ops;
struct {
php_http_message_parser_t *parser;
#endif
} php_http_client_t;
-PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
+PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
PHP_HTTP_API php_http_client_t *php_http_client_copy(php_http_client_t *from, php_http_client_t *to);
PHP_HTTP_API STATUS php_http_client_exec(php_http_client_t *h, php_http_message_t *msg);
PHP_HTTP_API STATUS php_http_client_reset(php_http_client_t *h);
static int php_http_client_datashare_compare_handles(void *h1, void *h2);
-PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
+PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
{
php_http_client_datashare_t *free_h = NULL;
if (rf) {
h->rf = rf;
} else if (ops->rsrc) {
- h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
}
TSRMLS_SET_CTX(h->ts);
h->ops->dtor(h);
}
zend_llist_destroy(&h->clients);
- php_http_resource_factory_free(&h->rf);
+ php_resource_factory_free(&h->rf);
}
PHP_HTTP_API void php_http_client_datashare_free(php_http_client_datashare_t **h)
typedef STATUS (*php_http_client_datashare_setopt_func_t)(struct php_http_client_datashare *h, php_http_client_datashare_setopt_opt_t opt, void *arg);
typedef struct php_http_client_datashare_ops {
- php_http_resource_factory_ops_t *rsrc;
+ php_resource_factory_ops_t *rsrc;
php_http_client_datashare_init_func_t init;
php_http_client_datashare_copy_func_t copy;
php_http_client_datashare_dtor_func_t dtor;
typedef struct php_http_client_datashare {
void *ctx;
- php_http_resource_factory_t *rf;
+ php_resource_factory_t *rf;
php_http_client_datashare_ops_t *ops;
zend_llist clients;
#ifdef ZTS
PHP_MINIT_FUNCTION(http_client_datashare);
-PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
+PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_copy(php_http_client_datashare_t *from, php_http_client_datashare_t *to);
PHP_HTTP_API void php_http_client_datashare_dtor(php_http_client_datashare_t *h);
PHP_HTTP_API void php_http_client_datashare_free(php_http_client_datashare_t **h);
if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_client_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.client_ops) {
zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
- php_http_resource_factory_t *rf = NULL;
+ php_resource_factory_t *rf = NULL;
if (Z_STRLEN_P(phi)) {
char *name_str;
size_t name_len;
- php_http_persistent_handle_factory_t *pf;
+ php_persistent_handle_factory_t *pf;
name_len = spprintf(&name_str, 0, "http_client.%s", Z_STRVAL_P(zdriver));
- if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
- rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+ if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+ rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void *)) php_persistent_handle_abandon);
}
efree(name_str);
zdriver = zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC);
if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_client_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.client_pool_ops) {
zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
- php_http_resource_factory_t *rf = NULL;
+ php_resource_factory_t *rf = NULL;
if (Z_STRLEN_P(phi)) {
char *name_str;
size_t name_len;
- php_http_persistent_handle_factory_t *pf;
+ php_persistent_handle_factory_t *pf;
name_len = spprintf(&name_str, 0, "http_client_pool.%s", Z_STRVAL_P(zdriver));
- if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
- rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+ if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+ rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void *)) php_persistent_handle_abandon);
}
efree(name_str);
zdriver = zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC);
if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_client_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.client_datashare_ops) {
zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
- php_http_resource_factory_t *rf = NULL;
+ php_resource_factory_t *rf = NULL;
if (Z_STRLEN_P(phi)) {
char *name_str;
size_t name_len;
- php_http_persistent_handle_factory_t *pf;
+ php_persistent_handle_factory_t *pf;
name_len = spprintf(&name_str, 0, "http_client_datashare.%s", Z_STRVAL_P(zdriver));
- if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
- rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+ if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+ rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void *)) php_persistent_handle_abandon);
}
efree(name_str);
#include "php_http_api.h"
-PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *h, php_http_client_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
+PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *h, php_http_client_pool_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
{
php_http_client_pool_t *free_h = NULL;
if (rf) {
h->rf = rf;
} else if (ops->rsrc) {
- h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
}
zend_llist_init(&h->clients.attached, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0);
zend_llist_init(&h->clients.finished, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0);
zend_llist_clean(&h->clients.finished);
zend_llist_clean(&h->clients.attached);
- php_http_resource_factory_free(&h->rf);
+ php_resource_factory_free(&h->rf);
}
PHP_HTTP_API void php_http_client_pool_free(php_http_client_pool_t **h) {
typedef STATUS (*php_http_client_pool_setopt_func_t)(struct php_http_client_pool *p, php_http_client_pool_setopt_opt_t opt, void *arg);
typedef struct php_http_client_pool_ops {
- php_http_resource_factory_ops_t *rsrc;
+ php_resource_factory_ops_t *rsrc;
php_http_client_pool_init_func_t init;
php_http_client_pool_copy_func_t copy;
php_http_client_pool_dtor_func_t dtor;
typedef struct php_http_client_pool {
void *ctx;
- php_http_resource_factory_t *rf;
+ php_resource_factory_t *rf;
php_http_client_pool_ops_t *ops;
struct {
#endif
} php_http_client_pool_t;
-PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *pool, php_http_client_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
+PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *pool, php_http_client_pool_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_copy(php_http_client_pool_t *from, php_http_client_pool_t *to);
PHP_HTTP_API void php_http_client_pool_dtor(php_http_client_pool_t *pool);
PHP_HTTP_API void php_http_client_pool_free(php_http_client_pool_t **pool);
/* resource_factory ops */
-static void *php_http_curl_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curl_ctor(void *opaque, void *init_arg TSRMLS_DC)
{
void *ch;
php_http_curl_client_t *ctx;
TSRMLS_FETCH_FROM_CTX(h->ts);
- if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+ if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "could not initialize curl handle");
return NULL;
}
void *copy;
TSRMLS_FETCH_FROM_CTX(from->ts);
- if (!(copy = php_http_resource_factory_handle_copy(from->rf, ctx->handle TSRMLS_CC))) {
+ if (!(copy = php_resource_factory_handle_copy(from->rf, ctx->handle TSRMLS_CC))) {
return NULL;
}
curl_easy_setopt(ctx->handle, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(ctx->handle, CURLOPT_DEBUGFUNCTION, NULL);
- php_http_resource_factory_handle_dtor(h->rf, ctx->handle TSRMLS_CC);
+ php_resource_factory_handle_dtor(h->rf, ctx->handle TSRMLS_CC);
php_http_buffer_dtor(&ctx->options.ranges);
php_http_buffer_dtor(&ctx->options.cookies);
return SUCCESS;
}
-static php_http_resource_factory_ops_t php_http_curl_client_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curl_client_resource_factory_ops = {
php_http_curl_ctor,
php_http_curl_copy,
php_http_curl_dtor
{
php_http_options_t *options;
- if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client.curl"), &php_http_curl_client_resource_factory_ops, NULL, NULL)) {
+ if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client.curl"), &php_http_curl_client_resource_factory_ops, NULL, NULL)) {
return FAILURE;
}
} php_http_curl_client_datashare_t;
-static void *php_http_curlsh_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curlsh_ctor(void *opaque, void *init_arg TSRMLS_DC)
{
return curl_share_init();
}
php_http_curl_client_datashare_t *curl;
TSRMLS_FETCH_FROM_CTX(h->ts);
- if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+ if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_DATASHARE, "could not initialize curl share handle");
return NULL;
}
php_http_curl_client_datashare_t *curl = h->ctx;
TSRMLS_FETCH_FROM_CTX(h->ts);
- php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
+ php_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
efree(curl);
h->ctx = NULL;
return SUCCESS;
}
-static php_http_resource_factory_ops_t php_http_curlsh_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curlsh_resource_factory_ops = {
php_http_curlsh_ctor,
NULL,
php_http_curlsh_dtor
PHP_MINIT_FUNCTION(http_curl_client_datashare)
{
- if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client_datashare.curl"), &php_http_curlsh_resource_factory_ops, NULL, NULL)) {
+ if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client_datashare.curl"), &php_http_curlsh_resource_factory_ops, NULL, NULL)) {
return FAILURE;
}
#endif
} php_http_curl_client_pool_t;
-static void *php_http_curlm_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curlm_ctor(void *opaque, void *init_arg TSRMLS_DC)
{
return curl_multi_init();
}
php_http_curl_client_pool_t *curl;
TSRMLS_FETCH_FROM_CTX(h->ts);
- if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+ if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "could not initialize curl pool handle");
return NULL;
}
curl->unfinished = 0;
php_http_client_pool_reset(h);
- php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
+ php_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
efree(curl);
h->ctx = NULL;
return SUCCESS;
}
-static php_http_resource_factory_ops_t php_http_curlm_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curlm_resource_factory_ops = {
php_http_curlm_ctor,
NULL,
php_http_curlm_dtor
PHP_MINIT_FUNCTION(http_curl_client_pool)
{
- if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client_pool.curl"), &php_http_curlm_resource_factory_ops, NULL, NULL)) {
+ if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client_pool.curl"), &php_http_curlm_resource_factory_ops, NULL, NULL)) {
return FAILURE;
}
PHP_HTTP_ARG_VAL(result_array, 1)
PHP_HTTP_END_ARGS;
-PHP_HTTP_EMPTY_ARGS(statPersistentHandles);
-
-PHP_HTTP_BEGIN_ARGS(cleanPersistentHandles, 0)
- PHP_HTTP_ARG_VAL(name, 0)
- PHP_HTTP_ARG_VAL(ident, 0)
-PHP_HTTP_END_ARGS;
-
static zend_class_entry *php_http_env_class_entry;
zend_class_entry *php_http_env_get_class_entry(void)
PHP_HTTP_ENV_ME(negotiateCharset)
PHP_HTTP_ENV_ME(negotiate)
- PHP_HTTP_ENV_ME(statPersistentHandles)
- PHP_HTTP_ENV_ME(cleanPersistentHandles)
-
EMPTY_FUNCTION_ENTRY
};
}
}
-PHP_METHOD(HttpEnv, statPersistentHandles)
-{
- if (SUCCESS == zend_parse_parameters_none()) {
- object_init(return_value);
- if (php_http_persistent_handle_statall(HASH_OF(return_value) TSRMLS_CC)) {
- return;
- }
- zval_dtor(return_value);
- }
- RETURN_FALSE;
-}
-
-PHP_METHOD(HttpEnv, cleanPersistentHandles)
-{
- char *name_str = NULL, *ident_str = NULL;
- int name_len = 0, ident_len = 0;
-
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!", &name_str, &name_len, &ident_str, &ident_len)) {
- php_http_persistent_handle_cleanup(name_str, name_len, ident_str, ident_len TSRMLS_CC);
- }
-}
-
#ifdef PHP_HTTP_HAVE_JSON
#include "ext/json/php_json.h"
PHP_METHOD(HttpEnv, negotiateEncoding);
PHP_METHOD(HttpEnv, negotiateContentType);
PHP_METHOD(HttpEnv, negotiate);
-PHP_METHOD(HttpEnv, statPersistentHandles);
-PHP_METHOD(HttpEnv, cleanPersistentHandles);
PHP_MINIT_FUNCTION(http_env);
PHP_RINIT_FUNCTION(http_env);
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | PECL :: http |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
- +--------------------------------------------------------------------+
- | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-#ifndef PHP_HTTP_DEBUG_PHANDLES
-# define PHP_HTTP_DEBUG_PHANDLES 0
-#endif
-#if PHP_HTTP_DEBUG_PHANDLES
-# undef inline
-# define inline
-#endif
-
-static HashTable php_http_persistent_handles_hash;
-#ifdef ZTS
-# define LOCK() tsrm_mutex_lock(php_http_persistent_handles_lock)
-# define UNLOCK() tsrm_mutex_unlock(php_http_persistent_handles_lock)
-static MUTEX_T php_http_persistent_handles_lock;
-#else
-# define LOCK()
-# define UNLOCK()
-#endif
-
-typedef struct php_http_persistent_handle_list {
- HashTable free;
- ulong used;
-} php_http_persistent_handle_list_t;
-
-typedef struct php_http_persistent_handle_provider {
- php_http_persistent_handle_list_t list; /* "ident" => array(handles) entries */
- php_http_resource_factory_t rf;
-} php_http_persistent_handle_provider_t;
-
-static inline php_http_persistent_handle_list_t *php_http_persistent_handle_list_init(php_http_persistent_handle_list_t *list)
-{
- int free_list;
-
- if ((free_list = !list)) {
- list = pemalloc(sizeof(php_http_persistent_handle_list_t), 1);
- }
-
- list->used = 0;
-
- if (SUCCESS != zend_hash_init(&list->free, 0, NULL, NULL, 1)) {
- if (free_list) {
- pefree(list, 1);
- }
- list = NULL;
- }
-
- return list;
-}
-
-static int php_http_persistent_handle_apply_cleanup_ex(void *pp, void *arg TSRMLS_DC)
-{
- php_http_resource_factory_t *rf = arg;
- void **handle = pp;
-
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "DESTROY: %p\n", *handle);
-#endif
- php_http_resource_factory_handle_dtor(rf, *handle TSRMLS_CC);
- return ZEND_HASH_APPLY_REMOVE;
-}
-
-static int php_http_persistent_handle_apply_cleanup(void *pp, void *arg TSRMLS_DC)
-{
- php_http_resource_factory_t *rf = arg;
- php_http_persistent_handle_list_t **listp = pp;
-
- zend_hash_apply_with_argument(&(*listp)->free, php_http_persistent_handle_apply_cleanup_ex, rf TSRMLS_CC);
- if ((*listp)->used) {
- return ZEND_HASH_APPLY_KEEP;
- }
- zend_hash_destroy(&(*listp)->free);
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "LSTFREE: %p\n", *listp);
-#endif
- pefree(*listp, 1);
- *listp = NULL;
- return ZEND_HASH_APPLY_REMOVE;
-}
-
-static inline void php_http_persistent_handle_list_dtor(php_http_persistent_handle_list_t *list, php_http_persistent_handle_provider_t *provider TSRMLS_DC)
-{
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "LSTDTOR: %p\n", list);
-#endif
- zend_hash_apply_with_argument(&list->free, php_http_persistent_handle_apply_cleanup_ex, &provider->rf TSRMLS_CC);
- zend_hash_destroy(&list->free);
-}
-
-static inline void php_http_persistent_handle_list_free(php_http_persistent_handle_list_t **list, php_http_persistent_handle_provider_t *provider TSRMLS_DC)
-{
- php_http_persistent_handle_list_dtor(*list, provider TSRMLS_CC);
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "LSTFREE: %p\n", *list);
-#endif
- pefree(*list, 1);
- *list = NULL;
-}
-
-static int php_http_persistent_handle_list_apply_dtor(void *listp, void *provider TSRMLS_DC)
-{
- php_http_persistent_handle_list_free(listp, provider TSRMLS_CC);
- return ZEND_HASH_APPLY_REMOVE;
-}
-
-static inline php_http_persistent_handle_list_t *php_http_persistent_handle_list_find(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len TSRMLS_DC)
-{
- php_http_persistent_handle_list_t **list, *new_list;
-
- if (SUCCESS == zend_symtable_find(&provider->list.free, ident_str, ident_len + 1, (void *) &list)) {
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "LSTFIND: %p\n", *list);
-#endif
- return *list;
- }
-
- if ((new_list = php_http_persistent_handle_list_init(NULL))) {
- if (SUCCESS == zend_symtable_update(&provider->list.free, ident_str, ident_len + 1, (void *) &new_list, sizeof(php_http_persistent_handle_list_t *), (void *) &list)) {
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "LSTFIND: %p (new)\n", *list);
-#endif
- return *list;
- }
- php_http_persistent_handle_list_free(&new_list, provider TSRMLS_CC);
- }
-
- return NULL;
-}
-
-static inline STATUS php_http_persistent_handle_do_acquire(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len, void **handle TSRMLS_DC)
-{
- ulong index;
- void **handle_ptr;
- php_http_persistent_handle_list_t *list;
-
- if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
- zend_hash_internal_pointer_end(&list->free);
- if (HASH_KEY_NON_EXISTANT != zend_hash_get_current_key(&list->free, NULL, &index, 0) && SUCCESS == zend_hash_get_current_data(&list->free, (void *) &handle_ptr)) {
- *handle = *handle_ptr;
- zend_hash_index_del(&list->free, index);
- } else {
- *handle = php_http_resource_factory_handle_ctor(&provider->rf TSRMLS_CC);
- }
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "CREATED: %p\n", *handle);
-#endif
- if (*handle) {
- ++provider->list.used;
- ++list->used;
- return SUCCESS;
- }
- } else {
- *handle = NULL;
- }
-
- return FAILURE;
-}
-
-static inline STATUS php_http_persistent_handle_do_release(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len, void **handle TSRMLS_DC)
-{
- php_http_persistent_handle_list_t *list;
-
- if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
- if (provider->list.used >= PHP_HTTP_G->persistent_handle.limit) {
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "DESTROY: %p\n", *handle);
-#endif
- php_http_resource_factory_handle_dtor(&provider->rf, *handle TSRMLS_CC);
- } else {
- if (SUCCESS != zend_hash_next_index_insert(&list->free, (void *) handle, sizeof(void *), NULL)) {
- return FAILURE;
- }
- }
-
- *handle = NULL;
- --provider->list.used;
- --list->used;
- return SUCCESS;
- }
-
- return FAILURE;
-}
-
-static inline STATUS php_http_persistent_handle_do_accrete(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len, void *old_handle, void **new_handle TSRMLS_DC)
-{
- php_http_persistent_handle_list_t *list;
-
- if ((*new_handle = php_http_resource_factory_handle_copy(&provider->rf, old_handle TSRMLS_CC))) {
- if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
- ++list->used;
- }
- ++provider->list.used;
- return SUCCESS;
- }
- return FAILURE;
-}
-
-static void php_http_persistent_handles_hash_dtor(void *p)
-{
- php_http_persistent_handle_provider_t *provider = (php_http_persistent_handle_provider_t *) p;
- TSRMLS_FETCH();
-
- zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_list_apply_dtor, provider TSRMLS_CC);
- zend_hash_destroy(&provider->list.free);
- php_http_resource_factory_dtor(&provider->rf);
-}
-
-PHP_MINIT_FUNCTION(http_persistent_handle)
-{
- zend_hash_init(&php_http_persistent_handles_hash, 0, NULL, php_http_persistent_handles_hash_dtor, 1);
-#ifdef ZTS
- php_http_persistent_handles_lock = tsrm_mutex_alloc();
-#endif
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(http_persistent_handle)
-{
- zend_hash_destroy(&php_http_persistent_handles_hash);
-#ifdef ZTS
- tsrm_mutex_free(php_http_persistent_handles_lock);
-#endif
- return SUCCESS;
-}
-
-PHP_HTTP_API STATUS php_http_persistent_handle_provide(const char *name_str, size_t name_len, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *))
-{
- STATUS status = FAILURE;
- php_http_persistent_handle_provider_t provider;
-
- LOCK();
- if (php_http_persistent_handle_list_init(&provider.list)) {
- if (php_http_resource_factory_init(&provider.rf, fops, data, dtor)) {
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "PROVIDE: %s\n", name_str);
-#endif
-
- if (SUCCESS == zend_symtable_update(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider, sizeof(php_http_persistent_handle_provider_t), NULL)) {
- status = SUCCESS;
- } else {
- php_http_resource_factory_dtor(&provider.rf);
- }
- }
- }
- UNLOCK();
-
- return status;
-}
-
-PHP_HTTP_API php_http_persistent_handle_factory_t *php_http_persistent_handle_concede(php_http_persistent_handle_factory_t *a, const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC)
-{
- STATUS status = FAILURE;
- php_http_persistent_handle_factory_t *free_a = NULL;
-
- if (!a) {
- free_a = a = emalloc(sizeof(*a));
- }
- memset(a, 0, sizeof(*a));
-
- LOCK();
- status = zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &a->provider);
- UNLOCK();
-
- if (SUCCESS == status) {
- a->ident.str = estrndup(ident_str, a->ident.len = ident_len);
- if (free_a) {
- a->free_on_abandon = 1;
- }
- } else {
- if (free_a) {
- efree(free_a);
- }
- a = NULL;
- }
-
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "CONCEDE: %p (%s) (%s)\n", a ? a->provider : NULL, name_str, ident_str);
-#endif
-
- return a;
-}
-
-PHP_HTTP_API void php_http_persistent_handle_abandon(php_http_persistent_handle_factory_t *a)
-{
- zend_bool f = a->free_on_abandon;
-
-#if PHP_HTTP_DEBUG_PHANDLES
- fprintf(stderr, "ABANDON: %p\n", a->provider);
-#endif
-
- STR_FREE(a->ident.str);
- memset(a, 0, sizeof(*a));
- if (f) {
- efree(a);
- }
-}
-
-PHP_HTTP_API void *php_http_persistent_handle_acquire(php_http_persistent_handle_factory_t *a TSRMLS_DC)
-{
- void *handle = NULL;
-
- LOCK();
- php_http_persistent_handle_do_acquire(a->provider, a->ident.str, a->ident.len, &handle TSRMLS_CC);
- UNLOCK();
-
- return handle;
-}
-
-PHP_HTTP_API void *php_http_persistent_handle_accrete(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC)
-{
- void *new_handle = NULL;
-
- LOCK();
- php_http_persistent_handle_do_accrete(a->provider, a->ident.str, a->ident.len, handle, &new_handle TSRMLS_CC);
- UNLOCK();
-
- return new_handle;
-}
-
-PHP_HTTP_API void php_http_persistent_handle_release(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC)
-{
- LOCK();
- php_http_persistent_handle_do_release(a->provider, a->ident.str, a->ident.len, &handle TSRMLS_CC);
- UNLOCK();
-}
-
-PHP_HTTP_API void php_http_persistent_handle_cleanup(const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC)
-{
- php_http_persistent_handle_provider_t *provider;
- php_http_persistent_handle_list_t *list;
-
- LOCK();
- if (name_str && name_len) {
- if (SUCCESS == zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
- if (ident_str && ident_len) {
- if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
- zend_hash_apply_with_argument(&list->free, php_http_persistent_handle_apply_cleanup_ex, &provider->rf TSRMLS_CC);
- }
- } else {
- zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_apply_cleanup, &provider->rf TSRMLS_CC);
- }
- }
- } else {
- HashPosition pos;
-
- FOREACH_HASH_VAL(pos, &php_http_persistent_handles_hash, provider) {
- if (ident_str && ident_len) {
- if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
- zend_hash_apply_with_argument(&list->free, php_http_persistent_handle_apply_cleanup_ex, &provider->rf TSRMLS_CC);
- }
- } else {
- zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_apply_cleanup, &provider->rf TSRMLS_CC);
- }
- }
- }
- UNLOCK();
-}
-
-PHP_HTTP_API HashTable *php_http_persistent_handle_statall(HashTable *ht TSRMLS_DC)
-{
- zval *zentry[2];
- HashPosition pos1, pos2;
- php_http_array_hashkey_t key1 = php_http_array_hashkey_init(0), key2 = php_http_array_hashkey_init(0);
- php_http_persistent_handle_provider_t *provider;
- php_http_persistent_handle_list_t **list;
-
- LOCK();
- if (zend_hash_num_elements(&php_http_persistent_handles_hash)) {
- if (!ht) {
- ALLOC_HASHTABLE(ht);
- zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0);
- }
-
- FOREACH_HASH_KEYVAL(pos1, &php_http_persistent_handles_hash, key1, provider) {
- MAKE_STD_ZVAL(zentry[0]);
- array_init(zentry[0]);
-
- FOREACH_HASH_KEYVAL(pos2, &provider->list.free, key2, list) {
- MAKE_STD_ZVAL(zentry[1]);
- array_init(zentry[1]);
- add_assoc_long_ex(zentry[1], ZEND_STRS("used"), (*list)->used);
- add_assoc_long_ex(zentry[1], ZEND_STRS("free"), zend_hash_num_elements(&(*list)->free));
- add_assoc_zval_ex(zentry[0], key2.str, key2.len, zentry[1]);
- }
-
- zend_symtable_update(ht, key1.str, key1.len, &zentry[0], sizeof(zval *), NULL);
- }
- } else if (ht) {
- ht = NULL;
- }
- UNLOCK();
-
- return ht;
-}
-
-static php_http_resource_factory_ops_t php_http_persistent_handle_rf_ops = {
- (php_http_resource_factory_handle_ctor_t) php_http_persistent_handle_acquire,
- (php_http_resource_factory_handle_copy_t) php_http_persistent_handle_accrete,
- (php_http_resource_factory_handle_dtor_t) php_http_persistent_handle_release
-};
-
-PHP_HTTP_API php_http_resource_factory_ops_t *php_http_persistent_handle_resource_factory_ops(void)
-{
- return &php_http_persistent_handle_rf_ops;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | PECL :: http |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
- +--------------------------------------------------------------------+
- | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_PERSISTENT_HANDLE_H
-#define PHP_HTTP_PERSISTENT_HANDLE_H
-
-typedef struct php_http_persistent_handle_factory {
- void *provider;
-
- struct {
- char *str;
- size_t len;
- } ident;
-
- unsigned free_on_abandon:1;
-} php_http_persistent_handle_factory_t;
-
-struct php_http_persistent_handle_globals {
- ulong limit;
- struct {
- ulong h;
- char *s;
- size_t l;
- } ident;
-};
-
-PHP_MINIT_FUNCTION(http_persistent_handle);
-PHP_MSHUTDOWN_FUNCTION(http_persistent_handle);
-
-PHP_HTTP_API STATUS php_http_persistent_handle_provide(const char *name_str, size_t name_len, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *));
-PHP_HTTP_API php_http_persistent_handle_factory_t *php_http_persistent_handle_concede(php_http_persistent_handle_factory_t *a, const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC);
-PHP_HTTP_API void php_http_persistent_handle_abandon(php_http_persistent_handle_factory_t *a);
-PHP_HTTP_API void *php_http_persistent_handle_acquire(php_http_persistent_handle_factory_t *a TSRMLS_DC);
-PHP_HTTP_API void php_http_persistent_handle_release(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC);
-PHP_HTTP_API void *php_http_persistent_handle_accrete(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC);
-
-PHP_HTTP_API php_http_resource_factory_ops_t *php_http_persistent_handle_resource_factory_ops(void);
-
-PHP_HTTP_API void php_http_persistent_handle_cleanup(const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC);
-PHP_HTTP_API HashTable *php_http_persistent_handle_statall(HashTable *ht TSRMLS_DC);
-
-#endif /* PHP_HTTP_PERSISTENT_HANDLE_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | PECL :: http |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
- +--------------------------------------------------------------------+
- | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-PHP_HTTP_API php_http_resource_factory_t *php_http_resource_factory_init(php_http_resource_factory_t *f, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data))
-{
- if (!f) {
- f = emalloc(sizeof(*f));
- }
- memset(f, 0, sizeof(*f));
-
- memcpy(&f->fops, fops, sizeof(*fops));
-
- f->data = data;
- f->dtor = dtor;
-
- f->refcount = 1;
-
- return f;
-}
-
-PHP_HTTP_API unsigned php_http_resource_factory_addref(php_http_resource_factory_t *rf)
-{
- return ++rf->refcount;
-}
-
-PHP_HTTP_API void php_http_resource_factory_dtor(php_http_resource_factory_t *f)
-{
- --f->refcount;
-
- if (!f->refcount) {
- if (f->dtor) {
- f->dtor(f->data);
- }
- }
-}
-
-PHP_HTTP_API void php_http_resource_factory_free(php_http_resource_factory_t **f)
-{
- if (*f) {
- php_http_resource_factory_dtor(*f);
- if (!(*f)->refcount) {
- efree(*f);
- *f = NULL;
- }
- }
-}
-
-PHP_HTTP_API void *php_http_resource_factory_handle_ctor(php_http_resource_factory_t *f TSRMLS_DC)
-{
- if (f->fops.ctor) {
- return f->fops.ctor(f->data TSRMLS_CC);
- }
- return NULL;
-}
-
-PHP_HTTP_API void *php_http_resource_factory_handle_copy(php_http_resource_factory_t *f, void *handle TSRMLS_DC)
-{
- if (f->fops.copy) {
- return f->fops.copy(f->data, handle TSRMLS_CC);
- }
- return NULL;
-}
-
-PHP_HTTP_API void php_http_resource_factory_handle_dtor(php_http_resource_factory_t *f, void *handle TSRMLS_DC)
-{
- if (f->fops.dtor) {
- f->fops.dtor(f->data, handle TSRMLS_CC);
- }
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | PECL :: http |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
- +--------------------------------------------------------------------+
- | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_RESOURCE_FACTORY_H
-#define PHP_HTTP_RESOURCE_FACTORY_H
-
-typedef void *(*php_http_resource_factory_handle_ctor_t)(void *opaque TSRMLS_DC);
-typedef void *(*php_http_resource_factory_handle_copy_t)(void *opaque, void *handle TSRMLS_DC);
-typedef void (*php_http_resource_factory_handle_dtor_t)(void *opaque, void *handle TSRMLS_DC);
-
-typedef struct php_http_resource_factory_ops {
- php_http_resource_factory_handle_ctor_t ctor;
- php_http_resource_factory_handle_copy_t copy;
- php_http_resource_factory_handle_dtor_t dtor;
-} php_http_resource_factory_ops_t;
-
-typedef struct php_http_resource_factory {
- php_http_resource_factory_ops_t fops;
-
- void *data;
- void (*dtor)(void *data);
-
- unsigned refcount;
-} php_http_resource_factory_t;
-
-PHP_HTTP_API php_http_resource_factory_t *php_http_resource_factory_init(php_http_resource_factory_t *f, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data));
-PHP_HTTP_API unsigned php_http_resource_factory_addref(php_http_resource_factory_t *rf);
-PHP_HTTP_API void php_http_resource_factory_dtor(php_http_resource_factory_t *f);
-PHP_HTTP_API void php_http_resource_factory_free(php_http_resource_factory_t **f);
-
-PHP_HTTP_API void *php_http_resource_factory_handle_ctor(php_http_resource_factory_t *f TSRMLS_DC);
-PHP_HTTP_API void *php_http_resource_factory_handle_copy(php_http_resource_factory_t *f, void *handle TSRMLS_DC);
-PHP_HTTP_API void php_http_resource_factory_handle_dtor(php_http_resource_factory_t *f, void *handle TSRMLS_DC);
-
-#endif /* PHP_HTTP_RESOURCE_FACTORY_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
+++ /dev/null
---TEST--
-persistent handles
---SKIPIF--
-<?php include "skipif.inc"; ?>
---FILE--
-<?php
-$f = new http\Client\Factory(array("persistentHandleId" => "foo"));
-$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
- ->setOptions(array("connecttimeout"=> 90, "timeout" =>300))
- ->send(null);
-$f = new http\Client\Factory(array("persistentHandleId" => "bar"));
-$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
- ->setOptions(array("connecttimeout"=> 90, "timeout" =>300));
-
-var_dump(http\Env::statPersistentHandles());
-http\Env::cleanPersistentHandles();
-var_dump(http\Env::statPersistentHandles());
-
-$r->send(null);
-
-var_dump(http\Env::statPersistentHandles());
-?>
-DONE
---EXPECTF--
-object(stdClass)#%d (3) {
- ["http_client.curl"]=>
- array(2) {
- ["foo"]=>
- array(2) {
- ["used"]=>
- int(0)
- ["free"]=>
- int(1)
- }
- ["bar"]=>
- array(2) {
- ["used"]=>
- int(1)
- ["free"]=>
- int(0)
- }
- }
- ["http_client_pool.curl"]=>
- array(0) {
- }
- ["http_client_datashare.curl"]=>
- array(0) {
- }
-}
-object(stdClass)#%d (3) {
- ["http_client.curl"]=>
- array(1) {
- ["bar"]=>
- array(2) {
- ["used"]=>
- int(1)
- ["free"]=>
- int(0)
- }
- }
- ["http_client_pool.curl"]=>
- array(0) {
- }
- ["http_client_datashare.curl"]=>
- array(0) {
- }
-}
-object(stdClass)#%d (3) {
- ["http_client.curl"]=>
- array(1) {
- ["bar"]=>
- array(2) {
- ["used"]=>
- int(1)
- ["free"]=>
- int(0)
- }
- }
- ["http_client_pool.curl"]=>
- array(0) {
- }
- ["http_client_datashare.curl"]=>
- array(0) {
- }
-}
-DONE
include "skipif.inc";
if (!@include_once "PHPUnit/Autoload.php") die("skip need PHPUnit in include_path");
?>
+--INI--
+date.timezone=Europe/Vienna
--FILE--
<?php
require_once "PHPUnit/Autoload.php";