cvs: pecl /http http_request_api.c php_http_request_api.h

From: Date: Sun, 12 Jun 2005 15:48:14 +0000
Subject: cvs: pecl /http http_request_api.c php_http_request_api.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-3264@lists.php.net to get a copy of this message
mike Sun Jun 12 11:48:14 2005 EDT Modified files: /pecl/http http_request_api.c php_http_request_api.h Log: - typos & allow passing NULL as curl handle in http_request() again' http://cvs.php.net/diff.php/pecl/http/http_request_api.c?r1=1.14&r2=1.15&ty=u Index: pecl/http/http_request_api.c diff -u pecl/http/http_request_api.c:1.14 pecl/http/http_request_api.c:1.15 --- pecl/http/http_request_api.c:1.14 Fri Jun 10 11:04:12 2005 +++ pecl/http/http_request_api.c Sun Jun 12 11:48:13 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: http_request_api.c,v 1.14 2005/06/10 15:04:12 mike Exp $ */ +/* $Id: http_request_api.c,v 1.15 2005/06/12 15:48:13 mike Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -702,10 +702,23 @@ /* {{{ 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) { - if (SUCCESS != http_request_init(ch, meth, url, body, options, response)) { - return FAILURE; + STATUS status; + zend_bool clean_curl; + + if ((clean_curl = (!ch))) { + if (!(ch = curl_easy_init())) { + http_error(E_WARNING, HTTP_E_CURL, "Could not initialize curl."); + return FAILURE; + } } - return http_request_exec(ch, info); + + status = ((SUCCESS == http_request_init(ch, meth, url, body, options, response)) && + (SUCCESS == http_request_exec(ch, info))) ? SUCCESS : FAILURE; + + if (clean_curl) { + curl_easy_cleanup(ch); + } + return status; } /* }}} */ @@ -846,7 +859,6 @@ zval *info = GET_PROP_EX(req, request, responseInfo); if (SUCCESS != http_request_object_requesthandler(req, request, body)) { - efree(body); http_error_ex(E_WARNING, HTTP_E_CURL, "Could not initialize HttpRequest object for attaching to the HttpRequestPool"); } else if (CURLM_OK != (code = curl_multi_add_handle(pool->ch, req->ch))) { http_error_ex(E_WARNING, HTTP_E_CURL, "Could not attach HttpRequest object to the HttpRequestPool: %s", curl_multi_strerror(code)); @@ -857,6 +869,7 @@ zend_llist_add_element(&pool->bodies, &body); return SUCCESS; } + efree(body); } return FAILURE; } @@ -870,7 +883,7 @@ fprintf(stderr, "Detaching request %p (pool: %p) from pool %p\n", req, req->pool, pool); #endif if (req->pool != pool) { - http_error_ex(E_WARNING, HTTP_E_CURL, "HttpRequest object is not attached to this HttpRequestPool (%p != %p)", req->pool, pool); + http_error(E_WARNING, HTTP_E_CURL, "HttpRequest object is not attached to this HttpRequestPool"); } else { CURLMcode code; http://cvs.php.net/diff.php/pecl/http/php_http_request_api.h?r1=1.10&r2=1.11&ty=u Index: pecl/http/php_http_request_api.h diff -u pecl/http/php_http_request_api.h:1.10 pecl/http/php_http_request_api.h:1.11 --- pecl/http/php_http_request_api.h:1.10 Fri Jun 10 11:04:13 2005 +++ pecl/http/php_http_request_api.h Sun Jun 12 11:48:13 2005 @@ -13,7 +13,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_http_request_api.h,v 1.10 2005/06/10 15:04:13 mike Exp $ */ +/* $Id: php_http_request_api.h,v 1.11 2005/06/12 15:48:13 mike Exp $ */ #ifndef PHP_HTTP_REQUEST_API_H #define PHP_HTTP_REQUEST_API_H @@ -92,7 +92,7 @@ extern void _http_request_data_free_slist(void *list); #define http_request_pool_responsehandler _http_request_pool_responsehandler -extern void http_request_pool_responsehandler(zval **req TSRMLS_DC); +extern void _http_request_pool_responsehandler(zval **req TSRMLS_DC); #define http_request_global_init _http_request_global_init extern STATUS _http_request_global_init(void);

« previous php.pecl.cvs (#3264) next »