X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_client_curl.c;h=4573df7e1ce7c1c76a1f04ce53b69f751898b3db;hp=5c1fecd9b5a52798818569cdf23c3f935fe28050;hb=refs%2Fheads%2Fv2.1.x;hpb=4be4fbf8e05455322c854bfc355fbaf9c3906ebf diff --git a/php_http_client_curl.c b/php_http_client_curl.c index 5c1fecd..4573df7 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -539,9 +539,11 @@ static STATUS php_http_curle_get_info(CURL *ch, HashTable *info) case CURLSSLBACKEND_NSS: backend = "nss"; break; +#if !PHP_HTTP_CURL_VERSION(7,39,0) case CURLSSLBACKEND_QSOSSL: backend = "qsossl"; break; +#endif case CURLSSLBACKEND_GSKIT: backend = "gskit"; break; @@ -1496,6 +1498,9 @@ static STATUS php_http_client_curl_handler_reset(php_http_client_curl_handler_t } curl_easy_setopt(ch, CURLOPT_URL, NULL); + curl_easy_setopt(ch, CURLOPT_CUSTOMREQUEST, NULL); + curl_easy_setopt(ch, CURLOPT_HTTPGET, 1L); + curl_easy_setopt(ch, CURLOPT_NOBODY, 0L); /* libcurl < 7.19.6 does not clear auth info with USERPWD set to NULL */ #if PHP_HTTP_CURL_VERSION(7,19,1) curl_easy_setopt(ch, CURLOPT_PROXYUSERNAME, NULL); @@ -1631,15 +1636,25 @@ static STATUS php_http_client_curl_handler_prepare(php_http_client_curl_handler_ php_http_message_update_headers(msg); if (zend_hash_num_elements(&msg->hdrs)) { php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0); - zval **header_val; + zval **header_val, *header_cpy; HashPosition pos; php_http_buffer_t header; +#if !PHP_HTTP_CURL_VERSION(7,23,0) + zval **ct = NULL; + + zend_hash_find(&msg->hdrs, ZEND_STRS("Content-Length"), (void *) &ct); +#endif php_http_buffer_init(&header); FOREACH_HASH_KEYVAL(pos, &msg->hdrs, header_key, header_val) { if (header_key.type == HASH_KEY_IS_STRING) { - zval *header_cpy = php_http_ztyp(IS_STRING, *header_val); - +#if !PHP_HTTP_CURL_VERSION(7,23,0) + /* avoid duplicate content-length header */ + if (ct && *ct == *header_val) { + continue; + } +#endif + header_cpy = php_http_ztyp(IS_STRING, *header_val); php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy)); php_http_buffer_fix(&header); curl->options.headers = curl_slist_append(curl->options.headers, header.data); @@ -2166,7 +2181,9 @@ PHP_MINIT_FUNCTION(http_client_curl) #if PHP_HTTP_CURL_VERSION(7,19,1) REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_301", CURL_REDIR_POST_301, CONST_CS|CONST_PERSISTENT); REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_302", CURL_REDIR_POST_302, CONST_CS|CONST_PERSISTENT); +#if PHP_HTTP_CURL_VERSION(7,26,0) REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_303", CURL_REDIR_POST_303, CONST_CS|CONST_PERSISTENT); +#endif REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_ALL", CURL_REDIR_POST_ALL, CONST_CS|CONST_PERSISTENT); #endif