-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CURLRequest keeping the last value provided by headers with the same name #5220
Conversation
…rovided by headers with the same name CURLRequest can now get and forward all headers including multiple headers with the same name
Fix Issue #5041 - Bug: CURLRequest keeps the last value provided by headers with the same name |
@NicolaeIotu Thank you for your PR! We ask that contributions have code commits signed. Could you sign? And there is no test code in your PR. Can you add test code? |
Please address kenjis comments. I will also add that if (isset($this->headers[$origName]) && is_array($this->headers[$origName]->getValue())) {
if (! is_array($value)) {
$value = [$value];
}
foreach ($value as $v) {
$this->appendHeader($origName, $v);
}
} else {
$this->headers[$origName] = new Header($origName, $value);
$this->headerMap[strtolower($origName)] = $origName;
} Likewise Can you give an example of where this is not working? |
Hi guys, Having deducted that, it seems that it is probably better to modify MessageTrait.php and eliminate My kind suggestion is that somebody else takes over and fixes this issue in a brand new commit because I'm not familiar with the framework and honestly I have to spend some time figuring out how to do tests in PHP/CodeIgniter. |
@NicolaeIotu thank you for your analysis and contribution! Your grasp of the language and framework would not have led me to believe you were new, so kudos on that. I understand what you're saying but you think there is a presupposition here that "some headers are multiple values and some are not". Notice that /**
* Sets a header and it's value.
*
* @param array|string|null $value
*
* @return $this
*/
public function setHeader(string $name, $value): self I believe the intent is that any header you want to have multiple values you pass in an array (for CURL requests this might be like I'm glad to hear a case otherwise, but that is my understanding of the current functionality. |
UPDATE:
So my original comment stands: you need to pass any multiple headers values as arrays. DISREGARD BELOW (left for reference) Out of curiosity, I went and looked which header you were actually trying to repeat (
So indeed, you are correct about how this should function but my description of header handling above is accurate. Basically: the framework does not support multiple headers with the same name, but should. This is a much bigger change than what we are discussing here, so I will create an issue for it and the team will have to look into the implications. If you feel like tackling it feel free to send a PR, but be mindful that we cannot implement breaking changes. |
@MGatner The truth is that CodeIgniter is very well documented. One just have to read the instructions. |
@MGatner A header having multiple values, multiple headers with the same name. They are different.
See #5041 (comment) |
I sent PR #8194 |
Awesome! Much appreciated |
Fixes #5041
CURLRequest can now get and forward all headers including multiple headers with the same name
Description
Basic minimal modifications to ensure multiple headers with the same name are correctly received and forwarded.