X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_client_curl.c;h=fed92fc078f2c4a95649c53901f5393c8c05483a;hp=4634b794ad52c46863d66e0fbc3289b4d5f0bac3;hb=a0884cdb00bb323c3c793809bc39e76d46cd74d4;hpb=692cfb168b5e4a52fe9aa43f9a62b0d0e1076f9c diff --git a/php_http_client_curl.c b/php_http_client_curl.c index 4634b79..fed92fc 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -1212,6 +1212,11 @@ static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC) { 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; @@ -1511,6 +1516,7 @@ static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC) } #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; @@ -2002,9 +2008,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 { @@ -2117,7 +2128,7 @@ static php_resource_factory_t *create_rf(php_http_client_t *h, php_http_client_e } /* only if the client itself is setup for persistence */ - if (h->rf->dtor == (void (*)(void*)) php_persistent_handle_abandon) { + if (php_resource_factory_is_persistent(h->rf)) { char *id_str = NULL; size_t id_len; int port = url->port ? url->port : 80; @@ -2138,7 +2149,7 @@ static php_resource_factory_t *create_rf(php_http_client_t *h, php_http_client_e } if (pf) { - rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void*)) php_persistent_handle_abandon); + rf = php_persistent_handle_resource_factory_init(NULL, pf); } else { rf = php_resource_factory_init(NULL, &php_http_curle_resource_factory_ops, NULL, NULL); }