Merge R_2_5
[m6w6/ext-http] / php_http_client_curl.c
index a4e84ced00cec07c97a0e44fdeecbff04d16914e..85f12b7734f4201d6c308687d52f9e471d3e8150 100644 (file)
@@ -1228,6 +1228,11 @@ static void php_http_curle_options_init(php_http_options_t *registry)
 {
        php_http_option_t *opt;
 
 {
        php_http_option_t *opt;
 
+       /* url options */
+#if PHP_HTTP_CURL_VERSION(7,42,0)
+       php_http_option_register(registry, ZEND_STRL("path_as_is"), CURLOPT_PATH_AS_IS, IS_BOOL);
+#endif
+
        /* proxy */
        if ((opt = php_http_option_register(registry, ZEND_STRL("proxyhost"), CURLOPT_PROXY, IS_STRING))) {
                opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
        /* proxy */
        if ((opt = php_http_option_register(registry, ZEND_STRL("proxyhost"), CURLOPT_PROXY, IS_STRING))) {
                opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
@@ -1528,6 +1533,7 @@ static void php_http_curle_options_init(php_http_options_t *registry)
                }
 #endif
 #if PHP_HTTP_CURL_VERSION(7,39,0)
                }
 #endif
 #if PHP_HTTP_CURL_VERSION(7,39,0)
+               /* FIXME: see http://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html#AVAILABILITY */
                if ((opt = php_http_option_register(registry, ZEND_STRL("pinned_publickey"), CURLOPT_PINNEDPUBLICKEY, IS_STRING))) {
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
                if ((opt = php_http_option_register(registry, ZEND_STRL("pinned_publickey"), CURLOPT_PINNEDPUBLICKEY, IS_STRING))) {
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
@@ -2027,9 +2033,14 @@ static ZEND_RESULT_CODE php_http_client_curl_handler_prepare(php_http_client_cur
         * See also https://tools.ietf.org/html/rfc7231#section-5.1.1
         */
        if (PHP_HTTP_INFO(msg).request.method) {
         * See also https://tools.ietf.org/html/rfc7231#section-5.1.1
         */
        if (PHP_HTTP_INFO(msg).request.method) {
-               if (!strcasecmp("PUT", PHP_HTTP_INFO(msg).request.method)) {
+               switch(php_http_select_str(PHP_HTTP_INFO(msg).request.method, 2, "HEAD", "PUT")) {
+               case 0:
+                       curl_easy_setopt(curl->handle, CURLOPT_NOBODY, 1L);
+                       break;
+               case 1:
                        curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1L);
                        curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1L);
-               } else {
+                       break;
+               default:
                        curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, PHP_HTTP_INFO(msg).request.method);
                }
        } else {
                        curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, PHP_HTTP_INFO(msg).request.method);
                }
        } else {