* added POST support to HTTPi_Request
authorMichael Wallner <mike@php.net>
Tue, 22 Feb 2005 20:46:49 +0000 (20:46 +0000)
committerMichael Wallner <mike@php.net>
Tue, 22 Feb 2005 20:46:49 +0000 (20:46 +0000)
http.c
http_api.c
package.xml
php_http.h
php_http_api.h

diff --git a/http.c b/http.c
index 4f375f709ff38db43dbc33e06d69edb820fe6430..2cb48af5c2efd6355dbabd6b7bf977b6e33750d4 100644 (file)
--- a/http.c
+++ b/http.c
@@ -117,8 +117,6 @@ function_entry http_functions[] = {
 #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v))
 #define HASH_ORNULL(z) ((z) ? Z_ARRVAL_P(z) : NULL)
 #define NO_ARGS if (ZEND_NUM_ARGS()) WRONG_PARAM_COUNT
-#define HTTP_URL_ARGSEP_OVERRIDE zend_alter_ini_entry("arg_separator.output", sizeof("arg_separator.output") - 1, "&", 1, ZEND_INI_ALL, ZEND_INI_STAGE_RUNTIME)
-#define HTTP_URL_ARGSEP_RESTORE zend_restore_ini_entry("arg_separator.output", sizeof("arg_separator.output") - 1, ZEND_INI_STAGE_RUNTIME)
 
 #define array_copy(src, dst) zend_hash_copy(Z_ARRVAL_P(dst), Z_ARRVAL_P(src), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *))
 #define array_merge(src, dst) zend_hash_merge(Z_ARRVAL_P(dst), Z_ARRVAL_P(src), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *), 1)
@@ -254,7 +252,7 @@ zend_object_value _httpi_response_new_object(zend_class_entry *ce TSRMLS_DC)
        zend_object_value ov;
        httpi_response_object *o;
 
-       o = ecalloc(sizeof(httpi_response_object), 1);
+       o = ecalloc(1, sizeof(httpi_response_object));
        o->zo.ce = ce;
 
        ALLOC_HASHTABLE(OBJ_PROP(o));
@@ -738,6 +736,9 @@ static zend_object_handlers httpi_request_object_handlers;
 typedef struct {
        zend_object zo;
        CURL *ch;
+       
+       struct curl_httppost *post_data[2];
+       
 } httpi_request_object;
 
 #define httpi_request_declare_default_properties(ce) _httpi_request_declare_default_properties(ce TSRMLS_CC)
@@ -746,6 +747,8 @@ static inline void _httpi_request_declare_default_properties(zend_class_entry *c
        DCL_PROP_N(PROTECTED, options);
        DCL_PROP_N(PROTECTED, responseInfo);
        DCL_PROP_N(PROTECTED, responseData);
+       DCL_PROP_N(PROTECTED, postData);
+       DCL_PROP_N(PROTECTED, postFiles);
 
        DCL_PROP(PROTECTED, long, method, HTTP_GET);
 
@@ -777,9 +780,11 @@ zend_object_value _httpi_request_new_object(zend_class_entry *ce TSRMLS_DC)
        zend_object_value ov;
        httpi_request_object *o;
 
-       o = ecalloc(sizeof(httpi_request_object), 1);
+       o = ecalloc(1, sizeof(httpi_request_object));
        o->zo.ce = ce;
        o->ch = curl_easy_init();
+       o->post_data[0] = NULL;
+       o->post_data[1] = NULL;
 
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
@@ -811,13 +816,16 @@ zend_function_entry httpi_request_class_methods[] = {
        PHP_ME(HTTPi_Request, getQueryData, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, addQueryData, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, unsetQueryData, NULL, ZEND_ACC_PUBLIC)
-/*
+       
        PHP_ME(HTTPi_Request, setPostData, NULL, ZEND_ACC_PUBLIC)
+       PHP_ME(HTTPi_Request, getPostData, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, addPostData, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, unsetPostData, NULL, ZEND_ACC_PUBLIC)
 
        PHP_ME(HTTPi_Request, addPostFile, NULL, ZEND_ACC_PUBLIC)
-*/
+       PHP_ME(HTTPi_Request, getPostFiles, NULL, ZEND_ACC_PUBLIC)
+       PHP_ME(HTTPi_Request, unsetPostFiles, NULL, ZEND_ACC_PUBLIC)
+       
        PHP_ME(HTTPi_Request, send, NULL, ZEND_ACC_PUBLIC)
 
        PHP_ME(HTTPi_Request, getResponseData, NULL, ZEND_ACC_PUBLIC)
@@ -846,6 +854,8 @@ PHP_METHOD(HTTPi_Request, __construct)
        INIT_PARR(obj, options);
        INIT_PARR(obj, responseInfo);
        INIT_PARR(obj, responseData);
+       INIT_PARR(obj, postData);
+       INIT_PARR(obj, postFiles);
 
        if (URL) {
                UPD_PROP(obj, string, url, URL);
@@ -868,6 +878,8 @@ PHP_METHOD(HTTPi_Request, __destruct)
        FREE_PARR(obj, options);
        FREE_PARR(obj, responseInfo);
        FREE_PARR(obj, responseData);
+       FREE_PARR(obj, postData);
+       FREE_PARR(obj, postFiles);
 }
 /* }}} */
 
@@ -1136,6 +1148,146 @@ PHP_METHOD(HTTPi_Request, unsetQueryData)
 }
 /* }}} */
 
+/* {{{ proto bool HTTPi_Request::addPostData(array post_data)
+ *
+ */
+PHP_METHOD(HTTPi_Request, addPostData)
+{
+       zval *post, *post_data;
+       getObject(httpi_request_object, obj);
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &post_data)) {
+               RETURN_FALSE;
+       }
+       
+       post = GET_PROP(obj, postData);
+       array_merge(post_data, post);
+       
+       RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool HTTPi_Request::setPostData(array post_data)
+ *
+ */
+PHP_METHOD(HTTPi_Request, setPostData)
+{
+       zval *post, *post_data;
+       getObject(httpi_request_object, obj);
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &post_data)) {
+               RETURN_FALSE;
+       }
+       
+       post = GET_PROP(obj, postData);
+       zend_hash_clean(Z_ARRVAL_P(post));
+       array_copy(post_data, post);
+       
+       RETURN_TRUE;
+}
+/* }}}*/
+
+/* {{{ proto array HTTPi_Request::getPostData()
+ *
+ */
+PHP_METHOD(HTTPi_Request, getPostData)
+{
+       zval *post_data;
+       getObject(httpi_request_object, obj);
+       
+       NO_ARGS;
+       
+       post_data = GET_PROP(obj, postData);
+       array_init(return_value);
+       array_copy(post_data, return_value);
+}
+/* }}} */
+
+/* {{{ proto void HTTPi_Request::unsetPostData()
+ *
+ */
+PHP_METHOD(HTTPi_Request, unsetPostData)
+{
+       zval *post_data;
+       getObject(httpi_request_object, obj);
+       
+       NO_ARGS;
+       
+       post_data = GET_PROP(obj, postData);
+       zend_hash_clean(Z_ARRVAL_P(post_data));
+}
+/* }}} */
+
+/* {{{ proto bool HTTPi_Request::addPostFile(string name, string file[, string content_type = "application/x-octetstream"])
+ *
+ */
+PHP_METHOD(HTTPi_Request, addPostFile)
+{
+       zval *files, *entry;
+       char *name, *file, *type = NULL;
+       int name_len, file_len, type_len = 0;
+       getObject(httpi_request_object, obj);
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &name, &name_len, &file, &file_len, &type, &type_len)) {
+               RETURN_FALSE;
+       }
+       
+       if (type_len) {
+               if (!strchr(type, '/')) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Content-Type '%s' doesn't seem to contain a primary and a secondary part", type);
+                       RETURN_FALSE;
+               }
+       } else {
+               type = "application/x-octetstream";
+               type_len = sizeof("application/x-octetstream") - 1;
+       }
+       
+       MAKE_STD_ZVAL(entry);
+       array_init(entry);
+       
+       add_assoc_stringl(entry, "name", name, name_len, 1);
+       add_assoc_stringl(entry, "type", type, type_len, 1);
+       add_assoc_stringl(entry, "file", file, file_len, 1);
+       
+       files  = GET_PROP(obj, postFiles);
+       add_next_index_zval(files, entry);
+       
+       RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array HTTPi_Request::getPostFiles()
+ *
+ */
+PHP_METHOD(HTTPi_Request, getPostFiles)
+{
+       zval *files;
+       getObject(httpi_request_object, obj);
+       
+       NO_ARGS;
+       
+       files = GET_PROP(obj, postFiles);
+       
+       array_init(return_value);
+       array_copy(files, return_value);
+}
+/* }}} */
+
+/* {{{ proto void HTTPi_Request::unsetPostFiles()
+ *
+ */
+PHP_METHOD(HTTPi_Request, unsetPostFiles)
+{
+       zval *files;
+       getObject(httpi_request_object, obj);
+       
+       NO_ARGS;
+       
+       files = GET_PROP(obj, postFiles);
+       zend_hash_clean(Z_ARRVAL_P(files));
+}
+/* }}} */
+
 /* {{{ proto array HTTPi_Request::getResponseData()
  *
  */
@@ -1212,7 +1364,7 @@ PHP_METHOD(HTTPi_Request, send)
 {
        STATUS status = FAILURE;
        zval *meth, *URL, *qdata, *opts, *info, *resp;
-       char *response_data, *request_uri, *uri;
+       char *response_data, *request_uri;
        size_t response_len;
        getObject(httpi_request_object, obj);
 
@@ -1230,10 +1382,8 @@ PHP_METHOD(HTTPi_Request, send)
        info  = GET_PROP(obj, responseInfo);
        resp  = GET_PROP(obj, responseData);
 
-       uri = http_absolute_uri(Z_STRVAL_P(URL), NULL);
-       request_uri = ecalloc(HTTP_URI_MAXLEN + 1, 1);
-       strcpy(request_uri, uri);
-       efree(uri);
+       // HTTP_URI_MAXLEN+1 big char *
+       request_uri = http_absolute_uri(Z_STRVAL_P(URL), NULL);
 
        if (Z_STRLEN_P(qdata) && (strlen(request_uri) < HTTP_URI_MAXLEN)) {
                if (!strchr(request_uri, '?')) {
@@ -1255,6 +1405,68 @@ PHP_METHOD(HTTPi_Request, send)
                break;
 
                case HTTP_POST:
+                       {
+                               zval *post_files, *post_data, **data;
+                               
+                               post_files = GET_PROP(obj, postFiles);
+                               post_data  = GET_PROP(obj, postData);
+                               
+                               if (!zend_hash_num_elements(Z_ARRVAL_P(post_files))) {
+
+                                       /* urlencoded post */
+                                       status = http_post_array_ex(obj->ch, request_uri, Z_ARRVAL_P(post_data), Z_ARRVAL_P(opts), Z_ARRVAL_P(info), &response_data, &response_len);
+                                       
+                               } else {
+                               
+                                       /*
+                                        * multipart post 
+                                        */
+                                       
+                                       /* normal data */
+                                       for (   zend_hash_internal_pointer_reset(Z_ARRVAL_P(post_data));
+                                                       zend_hash_get_current_data(Z_ARRVAL_P(post_data), (void **) &data) == SUCCESS;
+                                                       zend_hash_move_forward(Z_ARRVAL_P(post_data))) {
+                                               
+                                               char *key;
+                                               long idx;
+                                               
+                                               if (HASH_KEY_IS_STRING == zend_hash_get_current_key(Z_ARRVAL_P(post_data), &key, &idx, 0)) {
+                                                       convert_to_string_ex(data);
+                                                       curl_formadd(&obj->post_data[0], &obj->post_data[1],
+                                                               CURLFORM_COPYNAME,                      key,
+                                                               CURLFORM_COPYCONTENTS,          Z_STRVAL_PP(data),
+                                                               CURLFORM_CONTENTSLENGTH,        Z_STRLEN_PP(data),
+                                                               CURLFORM_END
+                                                       );
+                                               }
+                                       }
+                                       
+                                       /* file data */
+                                       for (   zend_hash_internal_pointer_reset(Z_ARRVAL_P(post_files));
+                                                       zend_hash_get_current_data(Z_ARRVAL_P(post_files), (void **) &data) == SUCCESS;
+                                                       zend_hash_move_forward(Z_ARRVAL_P(post_files))) {
+                                               
+                                               zval **file, **type, **name;
+                                               
+                                               if (
+                                                       SUCCESS == zend_hash_find(Z_ARRVAL_PP(data), "name", sizeof("name"), (void **) &name) &&
+                                                       SUCCESS == zend_hash_find(Z_ARRVAL_PP(data), "type", sizeof("type"), (void **) &type) &&
+                                                       SUCCESS == zend_hash_find(Z_ARRVAL_PP(data), "file", sizeof("file"), (void **) &file)
+                                               ) {
+                                               
+                                                       curl_formadd(&obj->post_data[0], &obj->post_data[1],
+                                                               CURLFORM_COPYNAME,              Z_STRVAL_PP(name),
+                                                               CURLFORM_FILE,                  Z_STRVAL_PP(file),
+                                                               CURLFORM_CONTENTTYPE,   Z_STRVAL_PP(type),
+                                                               CURLFORM_END
+                                                       );
+                                               }
+                                       }
+                                       
+                                       status = http_post_curldata_ex(obj->ch, request_uri, obj->post_data[0], Z_ARRVAL_P(opts), Z_ARRVAL_P(info), &response_data, &response_len);
+                                       curl_formfree(obj->post_data[0]);
+                               }
+                       }
                break;
 
                default:
index e2e04208a531e037ebaf47f5070558fbb5c32309..bb83e28bde4a77c70af6d601c39966ff8a3ab48e 100644 (file)
@@ -533,7 +533,7 @@ static inline void _http_curl_setopts(CURL *ch, const char *url, HashTable *opti
 
                if (qstr.c) {
                        curl_easy_setopt(ch, CURLOPT_COOKIE, qstr.c);
-                       efree(qstr.c);
+                       /* FIXXXME: mem-leak */
                }
        }
 
@@ -831,7 +831,7 @@ static STATUS http_ob_stack_get(php_ob_buffer *o, php_ob_buffer **s)
 PHP_HTTP_API char *_http_date(time_t t TSRMLS_DC)
 {
        struct tm *gmtime, tmbuf;
-       char *date = ecalloc(31, 1);
+       char *date = ecalloc(1, 31);
 
        gmtime = php_gmtime_r(&t, &tmbuf);
        snprintf(date, 30,
@@ -1021,7 +1021,7 @@ PHP_HTTP_API inline char *_http_etag(const void *data_ptr, const size_t data_len
        char ssb_buf[128] = {0};
        unsigned char digest[16];
        PHP_MD5_CTX ctx;
-       char *new_etag = ecalloc(33, 1);
+       char *new_etag = ecalloc(1, 33);
 
        PHP_MD5Init(&ctx);
 
@@ -1176,7 +1176,7 @@ PHP_HTTP_API STATUS _http_start_ob_handler(php_output_handler_func_t handler_fun
        int count, i;
 
        if (count = OG(ob_nesting_level)) {
-               stack = ecalloc(sizeof(php_ob_buffer *), count);
+               stack = ecalloc(count, sizeof(php_ob_buffer *));
 
                if (count > 1) {
                        zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP,
@@ -1291,7 +1291,7 @@ PHP_HTTP_API STATUS _http_send_etag(const char *etag,
        }
        HTTP_G(etag) = estrdup(etag);
 
-       etag_header = ecalloc(sizeof("ETag: \"\"") + etag_len, 1);
+       etag_header = ecalloc(1, sizeof("ETag: \"\"") + etag_len);
        sprintf(etag_header, "ETag: \"%s\"", etag);
        if (SUCCESS != (status = http_send_header(etag_header))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't send '%s' header", etag_header);
@@ -1306,7 +1306,7 @@ PHP_HTTP_API STATUS _http_send_cache_control(const char *cache_control,
        const size_t cc_len TSRMLS_DC)
 {
        STATUS status;
-       char *cc_header = ecalloc(sizeof("Cache-Control: ") + cc_len, 1);
+       char *cc_header = ecalloc(1, sizeof("Cache-Control: ") + cc_len);
 
        sprintf(cc_header, "Cache-Control: %s", cache_control);
        if (SUCCESS != (status = http_send_header(cc_header))) {
@@ -1338,7 +1338,7 @@ PHP_HTTP_API STATUS _http_send_content_type(const char *content_type,
        }
        HTTP_G(ctype) = estrndup(content_type, ct_len);
 
-       ct_header = ecalloc(sizeof("Content-Type: ") + ct_len, 1);
+       ct_header = ecalloc(1, sizeof("Content-Type: ") + ct_len);
        sprintf(ct_header, "Content-Type: %s", content_type);
 
        if (SUCCESS != (status = http_send_header(ct_header))) {
@@ -1358,10 +1358,10 @@ PHP_HTTP_API STATUS _http_send_content_disposition(const char *filename,
        char *cd_header;
 
        if (send_inline) {
-               cd_header = ecalloc(sizeof("Content-Disposition: inline; filename=\"\"") + f_len, 1);
+               cd_header = ecalloc(1, sizeof("Content-Disposition: inline; filename=\"\"") + f_len);
                sprintf(cd_header, "Content-Disposition: inline; filename=\"%s\"", filename);
        } else {
-               cd_header = ecalloc(sizeof("Content-Disposition: attachment; filename=\"\"") + f_len, 1);
+               cd_header = ecalloc(1, sizeof("Content-Disposition: attachment; filename=\"\"") + f_len);
                sprintf(cd_header, "Content-Disposition: attachment; filename=\"%s\"", filename);
        }
 
@@ -1431,7 +1431,7 @@ PHP_HTTP_API STATUS _http_cache_etag(const char *etag, const size_t etag_len,
 PHP_HTTP_API char *_http_absolute_uri(const char *url,
        const char *proto TSRMLS_DC)
 {
-       char URI[HTTP_URI_MAXLEN + 1], *PTR, *proto_ptr, *host, *path;
+       char *proto_ptr, *host, *path, *PTR, *URI = ecalloc(1, HTTP_URI_MAXLEN + 1);
        zval *zhost;
 
        if (!url || !strlen(url)) {
@@ -1443,10 +1443,11 @@ PHP_HTTP_API char *_http_absolute_uri(const char *url,
        /* Mess around with already absolute URIs */
        else if (proto_ptr = strstr(url, "://")) {
                if (!proto || !strncmp(url, proto, strlen(proto))) {
-                       return estrdup(url);
+                       strncpy(URI, url, HTTP_URI_MAXLEN);
+                       return URI;
                } else {
                        snprintf(URI, HTTP_URI_MAXLEN, "%s%s", proto, proto_ptr + 3);
-                       return estrdup(URI);
+                       return URI;
                }
        }
 
@@ -1477,16 +1478,11 @@ PHP_HTTP_API char *_http_absolute_uri(const char *url,
        }
 
        /* strip everything after a new line */
-       PTR = URI;
-       while (*PTR != 0) {
-               if (*PTR == '\n' || *PTR == '\r') {
-                       *PTR = 0;
-                       break;
-               }
-               PTR++;
+       if ((PTR = strchr(URI, '\r')) || (PTR = strchr(URI, '\n'))) {
+               PTR = 0;
        }
-
-       return estrdup(URI);
+       
+       return URI;
 }
 /* }}} */
 
@@ -1903,7 +1899,7 @@ PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded,
        char *d_ptr;
 
        *decoded_len = 0;
-       *decoded = (char *) ecalloc(encoded_len, 1);
+       *decoded = ecalloc(1, encoded_len);
        d_ptr = *decoded;
        e_ptr = encoded;
 
@@ -2192,23 +2188,31 @@ PHP_HTTP_API STATUS _http_post_data_ex(CURL *ch, const char *URL, char *postdata
 }
 /* }}} */
 
-/* {{{ STATUS http_post_array(char *, HashTable *, HashTable *, HashTable *, char **, size_t *) */
-PHP_HTTP_API STATUS _http_post_array(const char *URL, HashTable *postarray,
+/* {{{ STATUS http_post_array_ex(CURL *, char *, HashTable *, HashTable *, HashTable *, char **, size_t *) */
+PHP_HTTP_API STATUS _http_post_array_ex(CURL *ch, const char *URL, HashTable *postarray,
        HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC)
 {
        smart_str qstr = {0};
        STATUS status;
 
+       HTTP_URL_ARGSEP_OVERRIDE;
        if (php_url_encode_hash_ex(postarray, &qstr, NULL,0,NULL,0,NULL,0,NULL TSRMLS_CC) != SUCCESS) {
                if (qstr.c) {
                        efree(qstr.c);
                }
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not encode post data");
+               HTTP_URL_ARGSEP_RESTORE;
                return FAILURE;
        }
        smart_str_0(&qstr);
+       HTTP_URL_ARGSEP_RESTORE;
 
-       status = http_post_data(URL, qstr.c, qstr.len, options, info, data, data_len);
+       if (ch) {
+               status = http_post_data_ex(ch, URL, qstr.c, qstr.len, options, info, data, data_len);
+       } else {
+               status = http_post_data(URL, qstr.c, qstr.len, options, info, data, data_len);
+       }
+       
        if (qstr.c) {
                efree(qstr.c);
        }
@@ -2216,6 +2220,28 @@ PHP_HTTP_API STATUS _http_post_array(const char *URL, HashTable *postarray,
 }
 /* }}} */
 
+/* {{{ STATUS http_post_curldata_ex(CURL *, char *, curl_httppost *, HashTable *, HashTable *, char **, size_t *) */
+PHP_HTTP_API STATUS _http_post_curldata_ex(CURL *ch, const char *URL, 
+       struct curl_httppost *curldata, HashTable *options, HashTable *info, 
+       char **data, size_t *data_len TSRMLS_DC)
+{
+       http_curl_initbuf(CURLBUF_EVRY);
+       http_curl_setopts(ch, URL, options);
+       curl_easy_setopt(ch, CURLOPT_POST, 1);
+       curl_easy_setopt(ch, CURLOPT_HTTPPOST, curldata);
+
+       if (CURLE_OK != curl_easy_perform(ch)) {
+               http_curl_freebuf(CURLBUF_EVRY);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not perform request");
+               return FAILURE;
+       }
+       if (info) {
+               http_curl_getinfo(ch, info);
+       }
+       http_curl_movebuf(CURLBUF_EVRY, data, data_len);
+       return SUCCESS;}
+/* }}} */
+
 #endif
 /* }}} HAVE_CURL */
 
index 82621a69511d7e8bd853d979db0a691c2e0c7d4d..f8085c1e2d55892ee9547f21d5b1c966ea289c05 100644 (file)
   </maintainers>
 
   <release>
-    <version>0.5.1</version>
-    <date>2005-02-22</date>
+    <version>0.6.0</version>
+    <date>2005-02-00</date>
     <state>alpha</state>
     <notes><![CDATA[
-* added some compatibility checks for older libcurl versions
-* fixed some memory leaks
-* fixed a typo which made http_split_response() useless
-* fixed HTTPi_Request object destruction
+* added POST support to HTTPi_Request
 ]]>
     </notes>
   </release>
index c4fc38050873776aad9c82ded570cd42c8fd410f..0de3905e957ec065c36b6c15b8d05db9c4bbe8d5 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_EXT_HTTP_VERSION "0.5.0-dev"
+#define PHP_EXT_HTTP_VERSION "0.6.0-dev"
 
 /* make compile on Win32 */
 #include "php_streams.h"
@@ -110,11 +110,14 @@ PHP_METHOD(HTTPi_Request, getContentType);
 PHP_METHOD(HTTPi_Request, setQueryData);
 PHP_METHOD(HTTPi_Request, getQueryData);
 PHP_METHOD(HTTPi_Request, addQueryData);
-PHP_METHOD(HTTPi_Request, unsetQueryData);/*
+PHP_METHOD(HTTPi_Request, unsetQueryData);
 PHP_METHOD(HTTPi_Request, setPostData);
+PHP_METHOD(HTTPi_Request, getPostData);
 PHP_METHOD(HTTPi_Request, addPostData);
 PHP_METHOD(HTTPi_Request, unsetPostData);
-PHP_METHOD(HTTPi_Request, addPostFile);*/
+PHP_METHOD(HTTPi_Request, addPostFile);
+PHP_METHOD(HTTPi_Request, getPostFiles);
+PHP_METHOD(HTTPi_Request, unsetPostFiles);
 PHP_METHOD(HTTPi_Request, send);
 PHP_METHOD(HTTPi_Request, getResponseData);
 PHP_METHOD(HTTPi_Request, getResponseHeaders);
index 5dd7de8aa91cd00f14add641c8b13c4c12c7a120..bdce2adea704326d422addd732c507134fc3b702 100644 (file)
@@ -61,6 +61,11 @@ typedef enum {
 /* server vars shorthand */
 #define HTTP_SERVER_VARS Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])
 
+/* override arg_separator.output to "&" for data used in outgoing requests */
+#include "zend_ini.h"
+#define HTTP_URL_ARGSEP_OVERRIDE zend_alter_ini_entry("arg_separator.output", sizeof("arg_separator.output") - 1, "&", 1, ZEND_INI_ALL, ZEND_INI_STAGE_RUNTIME)
+#define HTTP_URL_ARGSEP_RESTORE zend_restore_ini_entry("arg_separator.output", sizeof("arg_separator.output") - 1, ZEND_INI_STAGE_RUNTIME)
+
 /* {{{ HAVE_CURL */
 #ifdef HTTP_HAVE_CURL
 #include <curl/curl.h>
@@ -211,8 +216,12 @@ PHP_HTTP_API STATUS _http_post_data(const char *URL, char *postdata, size_t post
 #define http_post_data_ex(c, u, pd, pl, o, i, d, l) _http_post_data_ex((c), (u), (pd), (pl), (o), (i), (d), (l) TSRMLS_CC)
 PHP_HTTP_API STATUS _http_post_data_ex(CURL *ch, const char *URL, char *postdata, size_t postdata_len, HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC);
 
-#define http_post_array(u, p, o, i, d, l) _http_post_array((u), (p), (o), (i), (d), (l) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_post_array(const char *URL, HashTable *postarray, HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC);
+#define http_post_array(u, p, o, i, d, l) _http_post_array_ex(NULL, (u), (p), (o), (i), (d), (l) TSRMLS_CC)
+#define http_post_array_ex(c, u, p, o, i, d, l) _http_post_array_ex((c), (u), (p), (o), (i), (d), (l) TSRMLS_CC)
+PHP_HTTP_API STATUS _http_post_array_ex(CURL *ch, const char *URL, HashTable *postarray, HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC);
+
+#define http_post_curldata_ex(c, u, h, o, i, d, l) _http_post_curldata_ex((c), (u), (h), (o), (i), (d), (l) TSRMLS_CC)
+PHP_HTTP_API STATUS _http_post_curldata_ex(CURL *ch, const char *URL, struct curl_httppost *curldata, HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC);
 
 #endif
 /* }}} HAVE_CURL */