Skip to content

Better authorization header handling in AddAuthenticationHeader#91

Merged
asgrim merged 1 commit into
php:mainfrom
alexandre-daubois:auth-header-process
Nov 15, 2024
Merged

Better authorization header handling in AddAuthenticationHeader#91
asgrim merged 1 commit into
php:mainfrom
alexandre-daubois:auth-header-process

Conversation

@alexandre-daubois
Copy link
Copy Markdown
Member

@alexandre-daubois alexandre-daubois commented Nov 14, 2024

By limiting the number of results that explode() returns, we're fine dealing with values containing a :. Also, it ease the check of the parts validity as the result is way more deterministic compared to calling to explode() without limit.

@asgrim asgrim self-requested a review November 15, 2024 09:36
@asgrim asgrim added the enhancement New feature or request label Nov 15, 2024
@asgrim asgrim added this to the 0.2.0 milestone Nov 15, 2024
@asgrim asgrim merged commit aad15d8 into php:main Nov 15, 2024
// @todo probably process this better
$headerParts = explode(':', $v);
$request = $request->withHeader(trim($headerParts[0]), trim($headerParts[1]));
$headerParts = array_map('trim', explode(':', $v, 2));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: 'trim' can be replaced with trim(...), first callable syntax is available since php 8.1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's true! But by using the "string syntax", the callable is resolved at the engine level instead of the language level which can be a bit faster. But if the project coding standards has a rule to use first class callable, let's update this part 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants