remove php_http_request_method.[ch]; add support for CURL_LOCK_DATA_SSL_SESSION,...
authorMichael Wallner <mike@php.net>
Thu, 22 Mar 2012 17:34:36 +0000 (17:34 +0000)
committerMichael Wallner <mike@php.net>
Thu, 22 Mar 2012 17:34:36 +0000 (17:34 +0000)
config9.m4
package.xml
php_http_api.h
php_http_curl.c
php_http_misc.c
php_http_misc.h
php_http_request.h
php_http_request_datashare.c
php_http_request_datashare.h
php_http_request_method.c [deleted file]
php_http_request_method.h [deleted file]

index 2a03cef672873456f48ab50d5f3d8f6d47bc1509..be7bdf9ad5737cee89ef94f2e79223471a2c18f3 100644 (file)
@@ -421,7 +421,6 @@ dnl ----
                php_http_curl.c \
                php_http_request_pool.c \
                php_http_request_datashare.c \
                php_http_curl.c \
                php_http_request_pool.c \
                php_http_request_datashare.c \
-               php_http_request_method.c \
                php_http_strlist.c \
                php_http_url.c \
                php_http_version.c \
                php_http_strlist.c \
                php_http_url.c \
                php_http_version.c \
@@ -464,7 +463,6 @@ dnl ----
                php_http_request.h \
                php_http_request_factory.h \
                php_http_curl.h \
                php_http_request.h \
                php_http_request_factory.h \
                php_http_curl.h \
-               php_http_request_method.h \
                php_http_request_pool.h \
                php_http_strlist.h \
                php_http_url.h \
                php_http_request_pool.h \
                php_http_strlist.h \
                php_http_url.h \
index 3f34a5998c87d70c8a67a19e3936de4cdbabc2b4..45467499bd9b5d57202007dbbcbe9811fd415d42 100644 (file)
@@ -41,7 +41,7 @@ Extended HTTP support. Again. Keep in mind that it's got the major version 2, be
 - Renamed http\Env\Request::getPost() to ::getForm()
 - Changed http\Env\Response::setContentDisposition() to take an http\Params like array as argument
 - Removed http\Env\Response::CONTENT_DISPOSOTION_* constants
 - Renamed http\Env\Request::getPost() to ::getForm()
 - Changed http\Env\Response::setContentDisposition() to take an http\Params like array as argument
 - Removed http\Env\Response::CONTENT_DISPOSOTION_* constants
-- Removed http\Env\Request\Method class; request methods are now used as simple strings
+- Removed http\Request\Method class; request methods are now used as simple strings
 ]]></notes>
  <contents>
   <dir name="/">
 ]]></notes>
  <contents>
   <dir name="/">
@@ -107,8 +107,6 @@ Extended HTTP support. Again. Keep in mind that it's got the major version 2, be
    <file role="src" name="php_http_request_factory.c"/>
    <file role="src" name="php_http_request_factory.h"/>
    <file role="src" name="php_http_request.h"/>
    <file role="src" name="php_http_request_factory.c"/>
    <file role="src" name="php_http_request_factory.h"/>
    <file role="src" name="php_http_request.h"/>
-   <file role="src" name="php_http_request_method.c"/>
-   <file role="src" name="php_http_request_method.h"/>
    <file role="src" name="php_http_request_pool.c"/>
    <file role="src" name="php_http_request_pool.h"/>
    <file role="src" name="php_http_resource_factory.c"/>
    <file role="src" name="php_http_request_pool.c"/>
    <file role="src" name="php_http_request_pool.h"/>
    <file role="src" name="php_http_resource_factory.c"/>
index a6ea120d9c05bb6d16c22aaed9a85f0dfc0c2f81..23e63cde1082e88483d5e020e723a6bae7eeb7b4 100644 (file)
@@ -98,7 +98,6 @@ typedef int STATUS;
 #include "php_http_request.h"
 #include "php_http_request_datashare.h"
 #include "php_http_request_factory.h"
 #include "php_http_request.h"
 #include "php_http_request_datashare.h"
 #include "php_http_request_factory.h"
-#include "php_http_request_method.h"
 #include "php_http_request_pool.h"
 #include "php_http_serf.h"
 #include "php_http_url.h"
 #include "php_http_request_pool.h"
 #include "php_http_serf.h"
 #include "php_http_url.h"
index 9bfeda8d81dc3b0c67a346c0f6e55a5135ae4725..f4a424458b8a882b1fe1069410dcde07e349eea9 100644 (file)
@@ -28,6 +28,7 @@ typedef struct php_http_curl_request {
                HashTable cache;
 
                struct curl_slist *headers;
                HashTable cache;
 
                struct curl_slist *headers;
+               struct curl_slist *resolve;
                php_http_buffer_t cookies;
 
                long redirects;
                php_http_buffer_t cookies;
 
                long redirects;
@@ -304,7 +305,7 @@ static STATUS php_http_curl_request_prepare(php_http_request_t *h, const char *m
        curl_easy_setopt(curl->handle, CURLOPT_URL, storage->url);
 
        /* request method */
        curl_easy_setopt(curl->handle, CURLOPT_URL, storage->url);
 
        /* request method */
-       switch (php_http_request_method_is(meth, 4, "GET", "HEAD", "POST", "PUT")) {
+       switch (php_http_select_str(meth, 4, "GET", "HEAD", "POST", "PUT")) {
                case 0:
                        curl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1L);
                        break;
                case 0:
                        curl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1L);
                        break;
@@ -624,6 +625,30 @@ static STATUS set_options(php_http_request_t *h, HashTable *options)
        if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("ipresolve"), IS_LONG)) && Z_LVAL_P(zoption)) {
                curl_easy_setopt(ch, CURLOPT_IPRESOLVE, Z_LVAL_P(zoption));
        }
        if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("ipresolve"), IS_LONG)) && Z_LVAL_P(zoption)) {
                curl_easy_setopt(ch, CURLOPT_IPRESOLVE, Z_LVAL_P(zoption));
        }
+#if PHP_HTTP_CURL_VERSION(7,21,3)
+       if (curl->options.resolve) {
+               curl_slist_free_all(curl->options.resolve);
+               curl->options.resolve = NULL;
+       }
+       if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("resolve"), IS_ARRAY))) {
+               php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
+               HashPosition pos;
+               zval **data;
+
+               FOREACH_KEYVAL(pos, zoption, key, data) {
+                       zval *cpy = php_http_ztyp(IS_STRING, *data);
+
+                       curl->options.resolve = curl_slist_append(curl->options.resolve, Z_STRVAL_P(cpy));
+
+                       zval_ptr_dtor(&cpy);
+               }
+       }
+#endif
+#if PHP_HTTP_CURL_VERSION(7,24,0)
+       if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("dns_servers"), IS_STRING)) && Z_STRLEN_P(zoption)) {
+               curl_easy_setopt(ch, CURLOPT_DNS_SERVERS, Z_STRVAL_P(zoption));
+       }
+#endif
 
        /* limits */
        if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("low_speed_limit"), IS_LONG))) {
 
        /* limits */
        if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("low_speed_limit"), IS_LONG))) {
@@ -1215,6 +1240,17 @@ static STATUS php_http_curl_request_datashare_setopt(php_http_request_datashare_
                        }
                        break;
 
                        }
                        break;
 
+#if PHP_HTTP_CURL_VERSION(7,23,0)
+               case PHP_HTTP_REQUEST_DATASHARE_OPT_SSLSESSIONS:
+                       if (CURLSHE_OK != (rc = curl_share_setopt(curl->handle, *((zend_bool *) arg) ? CURLSHOPT_SHARE : CURLSHOPT_UNSHARE, CURL_LOCK_DATA_SSL_SESSION))) {
+                               TSRMLS_FETCH_FROM_CTX(h->ts);
+
+                               php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_DATASHARE, "Could not %s sharing of SSL session data: %s",  *((zend_bool *) arg) ? "enable" : "disable", curl_share_strerror(rc));
+                               return FAILURE;
+                       }
+                       break;
+#endif
+
                default:
                        return FAILURE;
        }
                default:
                        return FAILURE;
        }
@@ -1606,6 +1642,12 @@ static STATUS php_http_curl_request_reset(php_http_request_t *h)
        curl_easy_setopt(ch, CURLOPT_HTTPPROXYTUNNEL, 0L);
        curl_easy_setopt(ch, CURLOPT_DNS_CACHE_TIMEOUT, 60L);
        curl_easy_setopt(ch, CURLOPT_IPRESOLVE, 0);
        curl_easy_setopt(ch, CURLOPT_HTTPPROXYTUNNEL, 0L);
        curl_easy_setopt(ch, CURLOPT_DNS_CACHE_TIMEOUT, 60L);
        curl_easy_setopt(ch, CURLOPT_IPRESOLVE, 0);
+#if PHP_HTTP_CURL_VERSION(7,21,3)
+       curl_easy_setopt(ch, CURLOPT_RESOLVE, NULL);
+#endif
+#if PHP_HTTP_CURL_VERSION(7,24,0)
+       curl_easy_setopt(ch, CURLOPT_DNS_SERVERS, NULL);
+#endif
        curl_easy_setopt(ch, CURLOPT_LOW_SPEED_LIMIT, 0L);
        curl_easy_setopt(ch, CURLOPT_LOW_SPEED_TIME, 0L);
        /* LFS weirdance
        curl_easy_setopt(ch, CURLOPT_LOW_SPEED_LIMIT, 0L);
        curl_easy_setopt(ch, CURLOPT_LOW_SPEED_TIME, 0L);
        /* LFS weirdance
index e4411e0aaf39efb2e654e46913d8287ec0beb001..fa4bbbf2854add35e959331ea20fc48065acc843 100644 (file)
@@ -116,6 +116,30 @@ size_t php_http_boundary(char *buf, size_t buf_len TSRMLS_DC)
        return snprintf(buf, buf_len, "%15.15F", PHP_HTTP_G->env.request.time * php_combined_lcg(TSRMLS_C));
 }
 
        return snprintf(buf, buf_len, "%15.15F", PHP_HTTP_G->env.request.time * php_combined_lcg(TSRMLS_C));
 }
 
+int php_http_select_str(const char *cmp, int argc, ...)
+{
+       va_list argv;
+       int match = -1;
+
+       if (cmp && argc > 0) {
+               int i;
+
+               va_start(argv, argc);
+               for (i = 0; i < argc; ++i) {
+                       const char *test = va_arg(argv, const char *);
+
+                       if (!strcasecmp(cmp, test)) {
+                               match = i;
+                               break;
+                       }
+               }
+               va_end(argv);
+       }
+
+       return match;
+}
+
+
 /* ARRAYS */
 
 int php_http_array_apply_append_func(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 /* ARRAYS */
 
 int php_http_array_apply_append_func(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
index 35c8951df9a94cebadd6ae09eaede19b6f46e6d4..6c00cc50c98094c301863d0ca8dd9019a6722ac9 100644 (file)
@@ -80,9 +80,9 @@ PHP_HTTP_API void php_http_sleep(double s);
 #define PHP_HTTP_MATCH_STRICT  (PHP_HTTP_MATCH_CASE|PHP_HTTP_MATCH_FULL)
 
 extern int php_http_match(const char *haystack, const char *needle, int flags);
 #define PHP_HTTP_MATCH_STRICT  (PHP_HTTP_MATCH_CASE|PHP_HTTP_MATCH_FULL)
 
 extern int php_http_match(const char *haystack, const char *needle, int flags);
-
 extern char *php_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
 extern size_t php_http_boundary(char *buf, size_t len TSRMLS_DC);
 extern char *php_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
 extern size_t php_http_boundary(char *buf, size_t len TSRMLS_DC);
+extern int php_http_select_str(const char *cmp, int argc, ...);
 
 static inline const char *php_http_locate_str(const char *h, size_t h_len, const char *n, size_t n_len)
 {
 
 static inline const char *php_http_locate_str(const char *h, size_t h_len, const char *n, size_t n_len)
 {
index 99f75d9c531fbc95750ef47396125b2ab2fcbef7..d535dc4998be130c1b02f56a18dda9b98f4021da 100644 (file)
@@ -13,7 +13,6 @@
 #ifndef PHP_HTTP_REQUEST_H
 #define PHP_HTTP_REQUEST_H
 
 #ifndef PHP_HTTP_REQUEST_H
 #define PHP_HTTP_REQUEST_H
 
-#include "php_http_request_method.h"
 #include "php_http_message_body.h"
 #include "php_http_message_parser.h"
 
 #include "php_http_message_body.h"
 #include "php_http_message_parser.h"
 
index a4502e51fd2900284f86cedfd702701330326182..5dbf9dd4db9e834eb669075e004ac11c14816dbd 100644 (file)
@@ -212,6 +212,8 @@ static void php_http_request_datashare_object_write_prop(zval *object, zval *mem
                        opt = PHP_HTTP_REQUEST_DATASHARE_OPT_COOKIES;
                } else if (!strcmp(pi->name, "dns")) {
                        opt = PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER;
                        opt = PHP_HTTP_REQUEST_DATASHARE_OPT_COOKIES;
                } else if (!strcmp(pi->name, "dns")) {
                        opt = PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER;
+               } else if (!strcmp(pi->name, "ssl")) {
+                       opt = PHP_HTTP_REQUEST_DATASHARE_OPT_SSLSESSIONS;
                } else {
                        return;
                }
                } else {
                        return;
                }
@@ -314,6 +316,7 @@ PHP_MINIT_FUNCTION(http_request_datashare)
 
        zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("cookie"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
        zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("dns"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
 
        zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("cookie"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
        zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("dns"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
+       zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("ssl"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
 
        return SUCCESS;
 }
 
        return SUCCESS;
 }
index a6939ac968c9b66bb0fdfef7234298ae448786cb..066a1bd437fd195659b4777b5f8744a4de0a28dc 100644 (file)
@@ -16,6 +16,7 @@
 typedef enum php_http_request_datashare_setopt_opt {
        PHP_HTTP_REQUEST_DATASHARE_OPT_COOKIES,
        PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER,
 typedef enum php_http_request_datashare_setopt_opt {
        PHP_HTTP_REQUEST_DATASHARE_OPT_COOKIES,
        PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER,
+       PHP_HTTP_REQUEST_DATASHARE_OPT_SSLSESSIONS,
 } php_http_request_datashare_setopt_opt_t;
 
 typedef struct php_http_request_datashare php_http_request_datashare_t;
 } php_http_request_datashare_setopt_opt_t;
 
 typedef struct php_http_request_datashare php_http_request_datashare_t;
diff --git a/php_http_request_method.c b/php_http_request_method.c
deleted file mode 100644 (file)
index 13561ad..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | 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 int php_http_request_method_is(const char *meth, int argc, ...)
-{
-       va_list argv;
-       int match = -1;
-
-       if (argc > 0) {
-               int i;
-
-               va_start(argv, argc);
-               for (i = 0; i < argc; ++i) {
-                       const char *test = va_arg(argv, const char *);
-
-                       if (!strcasecmp(meth, test)) {
-                               match = i;
-                               break;
-                       }
-               }
-               va_end(argv);
-       }
-
-       return match;
-}
-
-/*
- * 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
- */
-
diff --git a/php_http_request_method.h b/php_http_request_method.h
deleted file mode 100644 (file)
index 85eedbd..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | 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_REQUEST_METHOD_H
-#define PHP_HTTP_REQUEST_METHOD_H
-
-PHP_HTTP_API int php_http_request_method_is(const char *meth, int argc, ...);
-
-#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
- */
-