cvs: pecl /http http_methods.c http_request_api.c http_request_pool_api.c http_url_api.c php_http_request_api.h php_http_request_pool_api.h

From: Date: Tue, 14 Jun 2005 19:17:57 +0000
Subject: cvs: pecl /http http_methods.c http_request_api.c http_request_pool_api.c http_url_api.c php_http_request_api.h php_http_request_pool_api.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-3288@lists.php.net to get a copy of this message
mike Tue Jun 14 15:17:57 2005 EDT Modified files: /pecl/http http_methods.c http_request_api.c http_request_pool_api.c http_url_api.c php_http_request_api.h php_http_request_pool_api.h Log: - remove const qualifier from url param in http_request_*() - allow HttpRequestPools to be used only once

http://cvs.php.net/diff.php/pecl/http/http_methods.c?r1=1.51&r2=1.52&ty=u Index: pecl/http/http_methods.c diff -u pecl/http/http_methods.c:1.51 pecl/http/http_methods.c:1.52 --- pecl/http/http_methods.c:1.51 Tue Jun 14 13:39:17 2005 +++ pecl/http/http_methods.c Tue Jun 14 15:17:55 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: http_methods.c,v 1.51 2005/06/14 17:39:17 mike Exp $ */ +/* $Id: http_methods.c,v 1.52 2005/06/14 19:17:55 mike Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -2156,8 +2156,8 @@ * } * $pool->send(); * foreach ($urls as $url) { - * printf("%s (%s) is %s\n", - * $url, $req[$url]->getResponseInfo('effective_url'), + * printf("%s (%s) is %s\n", + * $url, $req[$url]->getResponseInfo('effective_url'), * $r->getResponseCode() == 200 ? 'alive' : 'not alive' * ); * } @@ -2255,11 +2255,16 @@ */ PHP_METHOD(HttpRequestPool, send) { + STATUS status; getObject(http_requestpool_object, obj); NO_ARGS; - RETURN_SUCCESS(http_request_pool_send(&obj->pool)); + SET_EH_THROW_HTTP(); + status = http_request_pool_send(&obj->pool); + SET_EH_NORMAL(); + + RETURN_SUCCESS(status); } /* }}} */ http://cvs.php.net/diff.php/pecl/http/http_request_api.c?r1=1.22&r2=1.23&ty=u Index: pecl/http/http_request_api.c diff -u pecl/http/http_request_api.c:1.22 pecl/http/http_request_api.c:1.23 --- pecl/http/http_request_api.c:1.22 Tue Jun 14 12:36:27 2005 +++ pecl/http/http_request_api.c Tue Jun 14 15:17:55 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: http_request_api.c,v 1.22 2005/06/14 16:36:27 mike Exp $ */ +/* $Id: http_request_api.c,v 1.23 2005/06/14 19:17:55 mike Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -153,7 +153,8 @@ { case COPY_STRING: { - char *new_str = estrdup((const char*) data); + char *new_str = estrdup(data); + //fprintf(stderr, "COPY STRING: %p (%s)\n", new_str, new_str); zend_llist_add_element(&HTTP_G(request).copies.strings, &new_str); return new_str; } @@ -181,6 +182,7 @@ /* {{{ void http_request_data_free_string(char **) */ void _http_request_data_free_string(void *string) { + //fprintf(stderr, "FREE STRING %p (%s)\n", *((char **)string), *((char **)string)); efree(*((char **)string)); } /* }}} */ @@ -318,7 +320,7 @@ /* }}} */ /* {{{ STATUS http_request_init(CURL *, http_request_method, char *, http_request_body *, HashTable *, phpstr *) */ -PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, const char *url, http_request_body *body, HashTable *options, phpstr *response TSRMLS_DC) +PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, char *url, http_request_body *body, HashTable *options, phpstr *response TSRMLS_DC) { zval *zoption; zend_bool range_req = 0; @@ -330,7 +332,7 @@ /* set options */ if (url) { - HTTP_CURL_OPT(URL, http_request_data_copy(COPY_STRING, (void *) url)); + HTTP_CURL_OPT(URL, http_request_data_copy(COPY_STRING, url)); } if (response) { @@ -701,7 +703,7 @@ /* }}} */ /* {{{ STATUS http_request_ex(CURL *, http_request_method, char *, http_request_body, HashTable, HashTable, phpstr *) */ -PHP_HTTP_API STATUS _http_request_ex(CURL *ch, http_request_method meth, const char *url, http_request_body *body, HashTable *options, HashTable *info, phpstr *response TSRMLS_DC) +PHP_HTTP_API STATUS _http_request_ex(CURL *ch, http_request_method meth, char *url, http_request_body *body, HashTable *options, HashTable *info, phpstr *response TSRMLS_DC) { STATUS status; zend_bool clean_curl; http://cvs.php.net/diff.php/pecl/http/http_request_pool_api.c?r1=1.2&r2=1.3&ty=u Index: pecl/http/http_request_pool_api.c diff -u pecl/http/http_request_pool_api.c:1.2 pecl/http/http_request_pool_api.c:1.3 --- pecl/http/http_request_pool_api.c:1.2 Tue Jun 14 12:03:10 2005 +++ pecl/http/http_request_pool_api.c Tue Jun 14 15:17:55 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: http_request_pool_api.c,v 1.2 2005/06/14 16:03:10 mike Exp $ */ +/* $Id: http_request_pool_api.c,v 1.3 2005/06/14 19:17:55 mike Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -59,6 +59,7 @@ } } + pool->sent = 0; pool->unfinished = 0; zend_llist_init(&pool->handles, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0); zend_llist_init(&pool->bodies, sizeof(http_request_body *), (llist_dtor_func_t) http_request_pool_freebody, 0); @@ -108,7 +109,7 @@ { getObjectEx(http_request_object, req, request); #if HTTP_DEBUG_REQPOOLS - fprintf(stderr, "Detaching request %p (pool: %p) from pool %p\n", req, req->pool, pool); + fprintf(stderr, "Detaching request %p from pool %p\n", req, pool); #endif if (req->pool != pool) { http_error(E_WARNING, HTTP_E_CURL, "HttpRequest object is not attached to this HttpRequestPool"); @@ -161,6 +162,12 @@ #if HTTP_DEBUG_REQPOOLS fprintf(stderr, "Attempt to send requests of pool %p\n", pool); #endif + if (pool->sent) { + http_error(E_WARNING, HTTP_E_CURL, "HttpRequestPools can only be used once"); + return FAILURE; + } else { + pool->sent = 1; + } while (http_request_pool_perform(pool)) { #if HTTP_DEBUG_REQPOOLS fprintf(stderr, "%d unfinished requests of pool %p remaining\n", pool->unfinished, pool); http://cvs.php.net/diff.php/pecl/http/http_url_api.c?r1=1.3&r2=1.4&ty=u Index: pecl/http/http_url_api.c diff -u pecl/http/http_url_api.c:1.3 pecl/http/http_url_api.c:1.4 --- pecl/http/http_url_api.c:1.3 Mon Jun 6 07:32:32 2005 +++ pecl/http/http_url_api.c Tue Jun 14 15:17:55 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: http_url_api.c,v 1.3 2005/06/06 11:32:32 mike Exp $ */ +/* $Id: http_url_api.c,v 1.4 2005/06/14 19:17:55 mike Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -54,7 +54,7 @@ php_url *purl, furl = {NULL}; size_t full_len = 0; zval *zhost = NULL; - char *scheme = NULL, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1); + char *scheme = NULL, *uri, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1); if ((!url || !url_len) && ( (!(url = SG(request_info).request_uri)) || @@ -63,7 +63,8 @@ return NULL; } - if (!(purl = php_url_parse((char *) url))) { + uri = estrndup(url, url_len); + if (!(purl = php_url_parse(uri))) { http_error_ex(E_WARNING, HTTP_E_PARSE, "Could not parse supplied URL: %s", url); return NULL; } @@ -123,6 +124,7 @@ efree(scheme); \ } \ php_url_free(purl); \ + efree(uri); \ return URL; \ } else { \ strcat(URL, add_string); \ @@ -172,6 +174,7 @@ efree(scheme); } php_url_free(purl); + efree(uri); return URL; } http://cvs.php.net/diff.php/pecl/http/php_http_request_api.h?r1=1.13&r2=1.14&ty=u Index: pecl/http/php_http_request_api.h diff -u pecl/http/php_http_request_api.h:1.13 pecl/http/php_http_request_api.h:1.14 --- pecl/http/php_http_request_api.h:1.13 Tue Jun 14 10:21:23 2005 +++ pecl/http/php_http_request_api.h Tue Jun 14 15:17:55 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_http_request_api.h,v 1.13 2005/06/14 14:21:23 mike Exp $ */ +/* $Id: php_http_request_api.h,v 1.14 2005/06/14 19:17:55 mike Exp $ */ #ifndef PHP_HTTP_REQUEST_API_H #define PHP_HTTP_REQUEST_API_H @@ -120,7 +120,7 @@ PHP_HTTP_API void _http_request_body_free(http_request_body *body TSRMLS_DC); #define http_request_init(ch, meth, url, body, options, response) _http_request_init((ch), (meth), (url), (body), (options), (response) TSRMLS_CC) -PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, const char *url, http_request_body *body, HashTable *options, phpstr *response TSRMLS_DC); +PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, char *url, http_request_body *body, HashTable *options, phpstr *response TSRMLS_DC); #define http_request_exec(ch, i) _http_request_exec((ch), (i) TSRMLS_CC) PHP_HTTP_API STATUS _http_request_exec(CURL *ch, HashTable *info TSRMLS_DC); @@ -130,7 +130,7 @@ #define http_request(meth, url, body, opt, info, resp) _http_request_ex(NULL, (meth), (url), (body), (opt), (info), (resp) TSRMLS_CC) #define http_request_ex(ch, meth, url, body, opt, info, resp) _http_request_ex((ch), (meth), (url), (body), (opt), (info), (resp) TSRMLS_CC) -PHP_HTTP_API STATUS _http_request_ex(CURL *ch, http_request_method meth, const char *URL, http_request_body *body, HashTable *options, HashTable *info, phpstr *response TSRMLS_DC); +PHP_HTTP_API STATUS _http_request_ex(CURL *ch, http_request_method meth, char *URL, http_request_body *body, HashTable *options, HashTable *info, phpstr *response TSRMLS_DC); #define http_get(u, o, i, r) _http_request_ex(NULL, HTTP_GET, (u), NULL, (o), (i), (r) TSRMLS_CC) #define http_get_ex(c, u, o, i, r) _http_request_ex((c), HTTP_GET, (u), NULL, (o), (i), (r) TSRMLS_CC) http://cvs.php.net/diff.php/pecl/http/php_http_request_pool_api.h?r1=1.1&r2=1.2&ty=u Index: pecl/http/php_http_request_pool_api.h diff -u pecl/http/php_http_request_pool_api.h:1.1 pecl/http/php_http_request_pool_api.h:1.2 --- pecl/http/php_http_request_pool_api.h:1.1 Tue Jun 14 10:21:23 2005 +++ pecl/http/php_http_request_pool_api.h Tue Jun 14 15:17:55 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_http_request_pool_api.h,v 1.1 2005/06/14 14:21:23 mike Exp $ */ +/* $Id: php_http_request_pool_api.h,v 1.2 2005/06/14 19:17:55 mike Exp $ */ #ifndef PHP_HTTP_REQUEST_POOL_API_H #define PHP_HTTP_REQUEST_POOL_API_H @@ -29,6 +29,7 @@ typedef struct { CURLM *ch; + zend_bool sent; zend_llist handles; zend_llist bodies; int unfinished;
« previous php.pecl.cvs (#3288) next »