X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_client_curl.c;h=85f12b7734f4201d6c308687d52f9e471d3e8150;hp=cb530649b1e87a4a72318a8815373ed88d1f3b01;hb=4bf1b4570329514fa00dc68c6e02f581c3792d73;hpb=8840a33028d28fa4f351b08b7502c1642c758af5 diff --git a/php_http_client_curl.c b/php_http_client_curl.c index cb53064..85f12b7 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -528,10 +528,11 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) case CURLSSLBACKEND_QSOSSL: backend = "qsossl"; break; -#endif +#else case CURLSSLBACKEND_GSKIT: backend = "gskit"; break; +#endif case CURLSSLBACKEND_POLARSSL: backend = "polarssl"; break; @@ -554,7 +555,7 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) } #endif -#if PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL) +#if (PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL)) || (PHP_HTTP_CURL_VERSION(7,34,0) && defined(PHP_HTTP_HAVE_NSS)) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_GSKIT)) { int i; zval ci_array, subarray; @@ -1227,6 +1228,11 @@ static void php_http_curle_options_init(php_http_options_t *registry) { 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; @@ -1249,6 +1255,11 @@ static void php_http_curle_options_init(php_http_options_t *registry) opt->setter = php_http_curle_option_set_proxyheader; } #endif +#if PHP_HTTP_CURL_VERSION(7,43,0) + if ((opt = php_http_option_register(registry, ZEND_STRL("proxy_service_name"), CURLOPT_PROXY_SERVICE_NAME, IS_STRING))) { + opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; + } +#endif #if PHP_HTTP_CURL_VERSION(7,40,0) if ((opt = php_http_option_register(registry, ZEND_STRL("unix_socket_path"), CURLOPT_UNIX_SOCKET_PATH, IS_STRING))) { @@ -1325,6 +1336,11 @@ static void php_http_curle_options_init(php_http_options_t *registry) if ((opt = php_http_option_register(registry, ZEND_STRL("httpauthtype"), CURLOPT_HTTPAUTH, IS_LONG))) { Z_LVAL(opt->defval) = CURLAUTH_ANYSAFE; } +#if PHP_HTTP_CURL_VERSION(7,43,0) + if ((opt = php_http_option_register(registry, ZEND_STRL("service_name"), CURLOPT_SERVICE_NAME, IS_STRING))) { + opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; + } +#endif /* redirects */ if ((opt = php_http_option_register(registry, ZEND_STRL("redirect"), CURLOPT_FOLLOWLOCATION, IS_LONG))) { @@ -1503,8 +1519,10 @@ static void php_http_curle_options_init(php_http_options_t *registry) } # endif #endif -#if PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL) - php_http_option_register(registry, ZEND_STRL("certinfo"), CURLOPT_CERTINFO, _IS_BOOL); +#if (PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL)) || (PHP_HTTP_CURL_VERSION(7,34,0) && defined(PHP_HTTP_HAVE_NSS)) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_GSKIT)) + if ((opt = php_http_option_register(registry, ZEND_STRL("certinfo"), CURLOPT_CERTINFO, _IS_BOOL))) { + ZVAL_FALSE(&opt->defval); + } #endif #if PHP_HTTP_CURL_VERSION(7,36,0) if ((opt = php_http_option_register(registry, ZEND_STRL("enable_npn"), CURLOPT_SSL_ENABLE_NPN, _IS_BOOL))) { @@ -1515,6 +1533,7 @@ static void php_http_curle_options_init(php_http_options_t *registry) } #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; @@ -1530,6 +1549,9 @@ static void php_http_curle_options_init(php_http_options_t *registry) if ((opt = php_http_option_register(registry, ZEND_STRL("tlsauthpass"), CURLOPT_TLSAUTH_PASSWORD, IS_STRING))) { opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; } +#endif +#if PHP_HTTP_CURL_VERSION(7,42,0) && (defined(PHP_HTTP_HAVE_NSS) || defined(PHP_HTTP_HAVE_DARWINSSL)) + php_http_option_register(registry, ZEND_STRL("falsestart"), CURLOPT_SSL_FALSESTART, _IS_BOOL); #endif } } @@ -2011,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) { - 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); - } else { + break; + default: curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, PHP_HTTP_INFO(msg).request.method); } } else {