header cleanups; fix IDE warnings
[m6w6/ext-http] / php_http_neon.c
index f0bc293cd3a6c9c7c988a41a43dbec52105e5433..8a65237f8556962c579c34d47ca9ba703b959f5c 100644 (file)
@@ -1,9 +1,21 @@
+/*
+    +--------------------------------------------------------------------+
+    | 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"
+
+#if PHP_HTTP_HAVE_NEON
 
-#include "php_http.h"
 #include "php_http_request.h"
 
-#include <ext/date/php_date.h>
-
 #include <neon/ne_auth.h>
 #include <neon/ne_compress.h>
 #include <neon/ne_session.h>
@@ -215,6 +227,7 @@ static STATUS set_options(php_http_request_t *h, HashTable *options)
        zval *zoption;
        int range_req = 0;
        php_http_neon_request_t *neon = h->ctx;
+       TSRMLS_FETCH_FROM_CTX(h->ts);
 
        /* proxy */
        if ((zoption = get_option(&neon->options.cache, options, ZEND_STRS("proxyhost"), IS_STRING))) {
@@ -353,7 +366,8 @@ static STATUS set_options(php_http_request_t *h, HashTable *options)
 
                if (PHP_HTTP_BUFFER_LEN(&rs)) {
                        /* ignore last comma */
-                       php_http_buffer_appendf(&neon->options.headers, "Range: bytes=%.*s" PHP_HTTP_CRLF, rs.used - 1, rs.data);
+                       int used = rs.used > INT_MAX ? INT_MAX : rs.used;
+                       php_http_buffer_appendf(&neon->options.headers, "Range: bytes=%.*s" PHP_HTTP_CRLF, used - 1, rs.data);
                        range_req = 1;
                }
                php_http_buffer_dtor(&rs);
@@ -423,7 +437,7 @@ static STATUS set_options(php_http_request_t *h, HashTable *options)
 
                        /* check whether cookies should not be urlencoded; default is to urlencode them */
                        if ((!(urlenc_cookies = get_option(&neon->options.cache, options, ZEND_STRS("encodecookies"), IS_BOOL))) || Z_BVAL_P(urlenc_cookies)) {
-                               php_http_url_encode_hash_recursive(HASH_OF(zoption), &neon->options.headers, "; ", lenof("; "), NULL, 0 TSRMLS_CC);
+                               php_http_url_encode_hash_ex(HASH_OF(zoption), &neon->options.headers, ZEND_STRS("; "), ZEND_STRS("="), NULL, 0 TSRMLS_CC);
                        } else {
                                HashPosition pos;
                                php_http_array_hashkey_t cookie_key = php_http_array_hashkey_init(0);
@@ -536,12 +550,13 @@ static php_http_request_t *php_http_neon_request_copy(php_http_request_t *from,
 static void php_http_neon_request_dtor(php_http_request_t *h)
 {
        php_http_neon_request_t *ctx = h->ctx;
+       TSRMLS_FETCH_FROM_CTX(h->ts);
 
        php_http_neon_request_reset(h);
        php_http_buffer_dtor(&ctx->options.headers);
        zend_hash_destroy(&ctx->options.cache);
 
-       php_http_request_progress_dtor(&ctx->progress);
+       php_http_request_progress_dtor(&ctx->progress TSRMLS_CC);
 
        efree(ctx);
        h->ctx = NULL;
@@ -550,6 +565,7 @@ static void php_http_neon_request_dtor(php_http_request_t *h)
 static STATUS php_http_neon_request_reset(php_http_request_t *h)
 {
        php_http_neon_request_t *neon = h->ctx;
+       TSRMLS_FETCH_FROM_CTX(h->ts);
 
        php_http_buffer_reset(&neon->options.headers);
        STR_SET(neon->options.useragent, NULL);
@@ -585,7 +601,7 @@ static STATUS php_http_neon_request_reset(php_http_request_t *h)
        neon->options.timeout.read = 0;
        neon->options.timeout.connect = 0;
 
-       php_http_request_progress_dtor(&neon->progress);
+       php_http_request_progress_dtor(&neon->progress TSRMLS_CC);
 
        return SUCCESS;
 }
@@ -602,7 +618,7 @@ static STATUS php_http_neon_request_exec(php_http_request_t *h, php_http_request
        php_http_neon_request_t *neon = h->ctx;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (!(meth = php_http_request_method_name(meth_id))) {
+       if (!(meth = php_http_request_method_name(meth_id TSRMLS_CC))) {
                php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", meth, url);
                return FAILURE;
        }
@@ -757,6 +773,7 @@ retry:
 static STATUS php_http_neon_request_setopt(php_http_request_t *h, php_http_request_setopt_opt_t opt, void *arg)
 {
        php_http_neon_request_t *neon = h->ctx;
+       TSRMLS_FETCH_FROM_CTX(h->ts);
 
        switch (opt) {
                case PHP_HTTP_REQUEST_OPT_SETTINGS:
@@ -889,3 +906,15 @@ PHP_MSHUTDOWN_FUNCTION(http_neon)
        ne_sock_exit();
        return SUCCESS;
 }
+
+#endif
+
+/*
+ * 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
+ */
+