AbstractDate::fromString('Expires: 0') fails #103
Description
Hi, we developed a custom Zend Event Listener for our Apigility application, this listener adds custom HTTP headers using the MvcEvent::EVENT_ROUTE
Zend event.
In our response headers we send an Expires: 0
header, this is to prevent bugs with Internet Explorer which seems to cache our payloads if we do not explicitly provide HTTP headers to disable caching.
When we provided the Expires: 0
HTTP header Zend Http fails with the following exception.
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character in D:\workspace\vgm-web-services\vendor\zendframework\zend-http\src\Header\AbstractDate.php:167 Stack trace:
#0 D:\workspace\vgm-web-services\vendor\zendframework\zend-http\src\Header\AbstractDate.php(167): DateTime->__construct('0', Object(DateTimeZone))
#1 D:\workspace\vgm-web-services\vendor\zendframework\zend-http\src\Header\AbstractDate.php(86): Zend\Http\Header\AbstractDate->setDate('0')
#2 D:\workspace\vgm-web-services\vendor\zendframework\zend-http\src\Headers.php(448): Zend\Http\Header\AbstractDate::fromString('Expires: 0')
#3 D:\workspace\vgm-web-services\vendor\zendframework\zend-http\src\Headers.php(352): Zend\Http\Headers->lazyLoadHeader(8)
#4 D:\workspace\vgm-web-services\vendor\zendframework\zend-mvc\src\ResponseSender\AbstractResponseSender.php(30): Zend\Http\Headers->current()
#5 D:\workspace\vgm-web-services\vendor\zendframework\zend-mvc\src\ResponseSender\PhpEnvironmentRespon in D:\workspace\vgm-web-services\vendor\zendframework\zend-http\src\Header\AbstractDate.php on line 169
As you can see the problem comes from the following instruction.
Zend\Http\Header\AbstractDate::fromString('Expires: 0')
IMO this behavior is not normal because as explained in the RFC https://tools.ietf.org/html/rfc2616#section-14.21 values which are not compliant with the date format must be treated.
HTTP/1.1 clients and caches MUST treat other invalid date formats,
especially including the value "0", as in the past (i.e., "already
expired").
So I think Zend should consider that invalid dates are equivalent to Thu, 01 Jan 1970 00:00:00 GMT
.
Do your agree with that ?
Perhaps this issue is also linked to #9.
Thanks