Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Do not raise exception on header retrival for invalid header lines #147

Merged
merged 3 commits into from
Apr 26, 2018
Merged

Do not raise exception on header retrival for invalid header lines #147

merged 3 commits into from
Apr 26, 2018

Conversation

michalbundyra
Copy link
Member

Fixes #146

@weierophinney
Copy link
Member

One thought I've had since posting #146 is that we could potentially check for exceptions in lazyLoadHeader(), and, if detected, attempt to create a GenericHeader instance. The main problem with that approach is that if the user was expecting a more specific header type, and planned to call methods on it, they will now get a PHP fatal error due to the method not existing.

As such, another option would be to allow access to the raw header lines somehow within the Headers class, so that users can at least introspect later if they are unsure why they are not getting a value for a header they expect.

@michalbundyra
Copy link
Member Author

As discussed with @weierophinney on slack we decided to change it slightly to have the following behaviour:

$headers->has(‘User-Agent’) -> false
$headers->has(‘useragent’)  -> true
$headers->get(‘User-Agent’) -> false
$headers->get(‘useragent’)  -> the generic header

Exception shouldn't be raised in any of these cases.

Now we disallow to use header name witout any separator. It is treated as
a different header. Only when header name contain space, dash, dot
or underscore is matched with dash-separated version.
@weierophinney weierophinney merged commit e8ad8ad into zendframework:master Apr 26, 2018
weierophinney added a commit that referenced this pull request Apr 26, 2018
Do not raise exception on header retrival for invalid header lines
weierophinney added a commit that referenced this pull request Apr 26, 2018
weierophinney added a commit that referenced this pull request Apr 26, 2018
weierophinney added a commit that referenced this pull request Apr 26, 2018
@weierophinney
Copy link
Member

Thanks, @webimpress!

@michalbundyra michalbundyra deleted the hotfix/146 branch April 26, 2018 15:35
roelvanduijnhoven pushed a commit to roelvanduijnhoven/zend-http that referenced this pull request May 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants