Skip to content

Commit 3b78f63

Browse files
remicolletm6w6
authored andcommitted
re-add curl 7.61 specific code
1 parent 7054914 commit 3b78f63

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

src/php_http_client_curl.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,50 @@ static ZEND_RESULT_CODE php_http_curle_set_option(php_http_option_t *opt, zval *
18801880
return rv;
18811881
}
18821882

1883+
#if !PHP_HTTP_CURL_VERSION(7,62,0)
1884+
static ZEND_RESULT_CODE php_http_curlm_option_set_pipelining_bl(php_http_option_t *opt, zval *value, void *userdata)
1885+
{
1886+
php_http_client_t *client = userdata;
1887+
php_http_client_curl_t *curl = client->ctx;
1888+
CURLM *ch = curl->handle->multi;
1889+
HashTable tmp_ht;
1890+
char **bl = NULL;
1891+
1892+
/* array of char *, ending with a NULL */
1893+
if (value && Z_TYPE_P(value) != IS_NULL) {
1894+
zval *entry;
1895+
HashTable *ht = HASH_OF(value);
1896+
int c = zend_hash_num_elements(ht);
1897+
char **ptr = ecalloc(c + 1, sizeof(char *));
1898+
1899+
bl = ptr;
1900+
1901+
zend_hash_init(&tmp_ht, c, NULL, ZVAL_PTR_DTOR, 0);
1902+
array_join(ht, &tmp_ht, 0, ARRAY_JOIN_STRINGIFY);
1903+
1904+
ZEND_HASH_FOREACH_VAL(&tmp_ht, entry)
1905+
{
1906+
*ptr++ = Z_STRVAL_P(entry);
1907+
}
1908+
ZEND_HASH_FOREACH_END();
1909+
}
1910+
1911+
if (CURLM_OK != curl_multi_setopt(ch, opt->option, bl)) {
1912+
if (bl) {
1913+
efree(bl);
1914+
zend_hash_destroy(&tmp_ht);
1915+
}
1916+
return FAILURE;
1917+
}
1918+
1919+
if (bl) {
1920+
efree(bl);
1921+
zend_hash_destroy(&tmp_ht);
1922+
}
1923+
return SUCCESS;
1924+
}
1925+
#endif
1926+
18831927
static inline ZEND_RESULT_CODE php_http_curlm_use_eventloop(php_http_client_t *h, php_http_client_curl_ops_t *ev_ops, zval *init_data)
18841928
{
18851929
php_http_client_curl_t *curl = h->ctx;
@@ -1978,6 +2022,26 @@ static void php_http_curlm_options_init(php_http_options_t *registry)
19782022
}
19792023
#endif
19802024

2025+
#if !PHP_HTTP_CURL_VERSION(7,62,0)
2026+
/* enable/disable HTTP pipelining */
2027+
php_http_option_register(registry, ZEND_STRL("pipelining"), CURLMOPT_PIPELINING, _IS_BOOL);
2028+
/* maximum number of requests in a pipeline */
2029+
if ((opt = php_http_option_register(registry, ZEND_STRL("max_pipeline_length"), CURLMOPT_MAX_PIPELINE_LENGTH, IS_LONG))) {
2030+
ZVAL_LONG(&opt->defval, 5);
2031+
}
2032+
/* chunk length threshold for pipelining */
2033+
php_http_option_register(registry, ZEND_STRL("chunk_length_penalty_size"), CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, IS_LONG);
2034+
/* size threshold for pipelining penalty */
2035+
php_http_option_register(registry, ZEND_STRL("content_length_penalty_size"), CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, IS_LONG);
2036+
/* pipelining server blacklist */
2037+
if ((opt = php_http_option_register(registry, ZEND_STRL("pipelining_server_bl"), CURLMOPT_PIPELINING_SERVER_BL, IS_ARRAY))) {
2038+
opt->setter = php_http_curlm_option_set_pipelining_bl;
2039+
}
2040+
/* pipelining host blacklist */
2041+
if ((opt = php_http_option_register(registry, ZEND_STRL("pipelining_site_bl"), CURLMOPT_PIPELINING_SITE_BL, IS_ARRAY))) {
2042+
opt->setter = php_http_curlm_option_set_pipelining_bl;
2043+
}
2044+
#endif
19812045
/* events */
19822046
if ((opt = php_http_option_register(registry, ZEND_STRL("use_eventloop"), 0, 0))) {
19832047
opt->setter = php_http_curlm_option_set_use_eventloop;

0 commit comments

Comments
 (0)