Uh oh!
There was an error while loading. Please reload this page.
Support for default request headers - #461
Conversation
nhedger
left a comment
There was a problem hiding this comment.
Hey 👋, nice PR ! Found a few typos here and there, hope it helps :)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
51imyyy
commented
Jun 24, 2022
Thank you @nhedger for your help :) |
clue
left a comment
There was a problem hiding this comment.
@51imyy Thank you very much for working on this, looks like a great feature and especially love the test suite and bonus points for added documentation!
Direction looks good to me, I've only added some remarks to bring this more in line with the rest of the project. Looking forward to get this sorted, keep it up! 👍
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| private function findCaseInsensitivHeader($headers, $header) | ||
| { | ||
| $found = null; | ||
| /** @var string $key */ |
There was a problem hiding this comment.
I agree that this seems reasonable and I'd love this to be true, but the array ["1" => "first"] uses (int) 1 as key automatically.
There was a problem hiding this comment.
the function got inlined. Im not that sure if that was your intention but i now changed it to "string|int $key". I could also just remove the annotation
SimonFrings
left a comment
There was a problem hiding this comment.
Hey @51imyy, great work on this so far 👍
I only found a few typos, the rest looks good to me. One thing I noticed is that you added quite a large number of commits for this, can you squash them together into one commit?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
frosty00
commented
Aug 3, 2022
I am getting banned from cloudflare for having the default user agent in this library. Is it possible to remove that header from here - http/src/Client/RequestData.php Line 32 in b3ff9c8 withoutHeader can remove the User-Agent specified in mergeRequestHeaders too. |
clue
commented
Aug 5, 2022
@frosty00 Good catch! Agree that it should be possible to remove the default @51imyy Good job with the PR so far! Is this something you can look into as part of this PR? 👍 |
Uh oh!
There was an error while loading. Please reload this page.
dinooo13
commented
Aug 12, 2022
How about removing the default User Agent from here: http/src/Client/RequestData.php Line 32 in b5a66a4 and re-adding it in the Browser constructor via your new withHeader() function? Then it should be easily removable with withoutHeader(). What do you think about this? |
frosty00
commented
Aug 12, 2022
yeah this looks like the correct solution |
f7f9bf0 to
32e0b33Compareadded the suggestion and squashed the commits. Now you can use the |
SimonFrings
left a comment
There was a problem hiding this comment.
@51imyy Great work 👍
I found a few more things that need to be changed. Most of them are nits, there's also one slightly larger issue describing a currently uncovered case.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| foreach ($this->defaultHeaders as $key => $value) { | ||
| if ($headers === array()) { | ||
| $headers = $this->defaultHeaders; | ||
| break; | ||
| } | ||
| foreach (\array_keys($headers) as $headerKey) { | ||
| if (\strcasecmp($headerKey, $key) !== 0) { | ||
| $headers[$key] = $value; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I am not sure if this shows the right behavior if a default header is set and and the same header (with a different value) is also passed as an explicit header into the requestMayBeStreaming() method. The current implementation will always overwrite the explicit header and I don't think that's what supposed to happen here. I recommend writing tests which use multiple explicit headers and multiple default headers. This way we can assure that these scenarios behave as expected.
There was a problem hiding this comment.
strcasecmp() returns 0 if the strings are the same (case-insensitiv). So only headers which are not in the explicit headers, will be added. But i foud a bug, while writing a test with multiple default and multiple explicit headers, which i have to fix.
There was a problem hiding this comment.
wrote another (longer) test and fixed the bug.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SimonFrings
left a comment
There was a problem hiding this comment.
@51imyy Sorry for the late response, here are some additional nits I found when looking over your changes.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
2f7d638 to
443fdf3Compare51imyyy
commented
Aug 30, 2022
applied the suggestions. I just added a missing opining tag (```php) to the README.md |
SimonFrings
commented
Sep 1, 2022
@51imyy I accidentally marked the first half of the examples (in |
@SimonFrings I thought it was intended, so i applied it 😅 . I can change it back. So the real intention was only to change |
SimonFrings
commented
Sep 1, 2022
@51imyy Yep, I messed my suggestion up. |
51imyyy
commented
Sep 1, 2022
@SimonFrings Changed it |
SimonFrings
left a comment
There was a problem hiding this comment.
Only indentation is a bit off.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
51imyyy
commented
Sep 1, 2022
appiled the suggestions. |
SimonFrings
left a comment
There was a problem hiding this comment.
The final touch, after this one I will stop to annoy you 😅
| add a request header for all following requests. | ||
| ```php |
There was a problem hiding this comment.
Can you add an empty line between these two (you already did this in the withoutHeader() description)
SimonFrings
left a comment
There was a problem hiding this comment.
Awesome work, you got my approval 👍
51imyyy
commented
Sep 1, 2022
Thank you :) |
clue
left a comment
There was a problem hiding this comment.
@51imyy Thanks for the quick updates! I've added some minor remarks below, otherwise LGTM and would love to get this shipped! ![]()
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ader user-agent to the default headers.
clue
left a comment
There was a problem hiding this comment.
@51imyy Thanks for the update, changes LGTM, now let's get this shipped!
Keep it up! 👍
Uh oh!
There was an error while loading. Please reload this page.
closes issue: #449
new methods for the class Browser (withHeader and withoutHeader)
With this methods you are able to set/remove default headers