mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.3' into PHP-8.4
This commit is contained in:
commit
139accecb4
3 changed files with 47 additions and 4 deletions
|
@ -1680,14 +1680,33 @@ static void php_cli_server_client_save_header(php_cli_server_client *client)
|
|||
{
|
||||
/* Wrap header value in a zval to add is to the HashTable which acts as an array */
|
||||
zval tmp;
|
||||
ZVAL_STR(&tmp, client->current_header_value);
|
||||
/* strip off the colon */
|
||||
zend_string *lc_header_name = zend_string_tolower_ex(client->current_header_name, /* persistent */ true);
|
||||
GC_MAKE_PERSISTENT_LOCAL(lc_header_name);
|
||||
|
||||
/* Add the wrapped zend_string to the HashTable */
|
||||
zend_hash_add(&client->request.headers, lc_header_name, &tmp);
|
||||
zend_hash_add(&client->request.headers_original_case, client->current_header_name, &tmp);
|
||||
zval *entry = zend_hash_find(&client->request.headers, lc_header_name);
|
||||
bool with_comma = !zend_string_equals_literal(lc_header_name, "set-cookie");
|
||||
|
||||
/**
|
||||
* `Set-Cookie` HTTP header being the exception, they can have 1 or more values separated
|
||||
* by a comma while still possibly be set separately by the client.
|
||||
**/
|
||||
if (!with_comma || entry == NULL) {
|
||||
ZVAL_STR(&tmp, client->current_header_value);
|
||||
} else {
|
||||
zend_string *curval = Z_STR_P(entry);
|
||||
zend_string *newval = zend_string_safe_alloc(1, ZSTR_LEN(curval), ZSTR_LEN(client->current_header_value) + 2, /* persistent */true);
|
||||
|
||||
memcpy(ZSTR_VAL(newval), ZSTR_VAL(curval), ZSTR_LEN(curval));
|
||||
memcpy(ZSTR_VAL(newval) + ZSTR_LEN(curval), ", ", 2);
|
||||
memcpy(ZSTR_VAL(newval) + ZSTR_LEN(curval) + 2, ZSTR_VAL(client->current_header_value), ZSTR_LEN(client->current_header_value) + 1);
|
||||
|
||||
ZVAL_STR(&tmp, newval);
|
||||
}
|
||||
|
||||
/* Add/Update the wrapped zend_string to the HashTable */
|
||||
zend_hash_update(&client->request.headers, lc_header_name, &tmp);
|
||||
zend_hash_update(&client->request.headers_original_case, client->current_header_name, &tmp);
|
||||
|
||||
zend_string_release_ex(lc_header_name, /* persistent */ true);
|
||||
zend_string_release_ex(client->current_header_name, /* persistent */ true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue