@@ -1678,19 +1678,20 @@ static int php_cli_server_client_read_request_on_fragment(php_http_parser *parse
1678
1678
1679
1679
static void php_cli_server_client_save_header (php_cli_server_client * client )
1680
1680
{
1681
- zval * entry ;
1682
1681
/* Wrap header value in a zval to add is to the HashTable which acts as an array */
1683
1682
zval tmp ;
1684
1683
/* strip off the colon */
1685
1684
zend_string * lc_header_name = zend_string_tolower_ex (client -> current_header_name , /* persistent */ true);
1686
1685
GC_MAKE_PERSISTENT_LOCAL (lc_header_name );
1687
1686
1687
+ zval * entry = zend_hash_find (& client -> request .headers , lc_header_name );
1688
+ bool is_forwarded_header = strstr (ZSTR_VAL (lc_header_name ), "forwarded" );
1689
+
1688
1690
/**
1689
1691
* **Forwarded** HTTP family headers can have 1 or more values separated by a comma while still
1690
1692
* possibly be set separately by the client.
1691
1693
**/
1692
- if (!strstr (ZSTR_VAL (lc_header_name ), "forwarded" ) ||
1693
- (entry = zend_hash_find (& client -> request .headers , lc_header_name )) == NULL ) {
1694
+ if ((entry == NULL && is_forwarded_header ) || !is_forwarded_header ) {
1694
1695
ZVAL_STR (& tmp , client -> current_header_value );
1695
1696
1696
1697
/* Add the wrapped zend_string to the HashTable */
0 commit comments