Skip to content

Fix merge HTTP headers with cURL options#956

Closed
Alkarex wants to merge 3 commits intosimplepie:masterfrom
FreshRSS:fix-merge-http-headers
Closed

Fix merge HTTP headers with cURL options#956
Alkarex wants to merge 3 commits intosimplepie:masterfrom
FreshRSS:fix-merge-http-headers

Conversation

@Alkarex
Copy link
Contributor

@Alkarex Alkarex commented Nov 25, 2025

HTTP headers were not merged properly, and were also not accounting for possible casing differences.
Follow-up of #912
It was for instance not possible to override the Accept header from the cURL options.
The existing code could not work properly because we were merging arrays of strings and not arrays of key-values, leading to strange duplicates.

Downstream: FreshRSS/FreshRSS#8246

HTTP headers were not merged properly, and were also not accounting for possible casing differences.
Follow-up of simplepie#912
It was for instance not possible to override the `Accept` header from the cURL options.
The existing code could not work properly because we were merging arrays of strings and not arrays of key-values, leading to strange duplicates.

Downstream: FreshRSS/FreshRSS#8246
if (!$force_fsockopen && function_exists('curl_exec')) {
$this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_CURL;
$fp = curl_init();
$headers2 = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed as $headers_inlined below

}
if (isset($curl_options[CURLOPT_HTTPHEADER])) {
if (is_array($curl_options[CURLOPT_HTTPHEADER])) {
$headers2 = array_merge($headers2, $curl_options[CURLOPT_HTTPHEADER]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not work because those are arrays of strings and not arrays of key-values.

Alkarex added a commit to Alkarex/simplepie that referenced this pull request Nov 25, 2025
HTTP headers were not merged properly, and were also not accounting for possible casing differences.
Follow-up of simplepie#912
It was for instance not possible to override the `Accept` header from the cURL options.
The existing code could not work properly because we were merging arrays of strings and not arrays of key-values, leading to strange duplicates.

Downstream: FreshRSS/FreshRSS#8246
Upstream: simplepie#956
Alkarex added a commit to FreshRSS/simplepie that referenced this pull request Nov 25, 2025
HTTP headers were not merged properly, and were also not accounting for possible casing differences.
Follow-up of simplepie#912
It was for instance not possible to override the `Accept` header from the cURL options.
The existing code could not work properly because we were merging arrays of strings and not arrays of key-values, leading to strange duplicates.

Downstream:
* FreshRSS/FreshRSS#8246

Upstream:
* simplepie#956
@Alkarex
Copy link
Contributor Author

Alkarex commented Nov 25, 2025

I need to rethink that. There are valid reasons for multiple identical HTTP headers such as:

Set-Cookie: a=1
Set-Cookie: b=2

@Alkarex Alkarex closed this Nov 25, 2025
@Alkarex Alkarex deleted the fix-merge-http-headers branch November 25, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant