Closed michalbundyra closed 6 years ago
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.
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.
Thanks, @webimpress!
Fixes #146