zend-http
zend-http copied to clipboard
invalid date in response header
Shouldn't that be catched?
[Zend\Http\Header\Exception\InvalidArgumentException]
Invalid date passed as string (0)
[Exception]
DateTime::__construct(): Failed to parse time string(0) at position 0 (0): Unexcepted character
Can you add informations?? code for example..
You can try to see this link http://stackoverflow.com/questions/17673102/php-datetime-failed-to-parse-time-string
@aight8 Please provide a way to reproduce this; right now, the exception stack you're listing seems reasonable, but I'm not sure how you got to it, nor what your expectations are.
Hi, @weierophinney
We have the same issue.
The error is thrown because of Fri, 04 Dec 2015 09:58:06 GMT + 1 the space between GMT and the + and the 1. Fri, 04 Dec 2015 09:58:06 GMT+1 parses without any issue.
see the trace.
2015-12-04T17:30:35+01:00 ERR (3): Exception:
1: Invalid date passed as string (Fri, 04 Dec 2015 09:58:06 GMT + 1)
2: DateTime::__construct(): Failed to parse time string (Fri, 04 Dec 2015 09:58:06 GMT + 1) at position 30 : Unexpected character +
Trace:
#0 /vendor/zendframework/zend-http/src/Header/AbstractDate.php(86): Zend\Http\Header\AbstractDate->setDate('Fri, 04 Dec 201...')
#1 /vendor/zendframework/zend-http/src/Headers.php(448): Zend\Http\Header\AbstractDate::fromString('Last-Modified: ...')
#2 /vendor/zendframework/zend-http/src/Headers.php(352): Zend\Http\Headers->lazyLoadHeader(5)
#3 /vendor/zendframework/zend-http/src/Response/Stream.php(201): Zend\Http\Headers->current()
#4 /vendor/zendframework/zend-http/src/Client.php(916): Zend\Http\Response\Stream::fromStream('HTTP/1.1 200 OK...', Resource id #11789)
#5 /...php(86): Zend\Http\Client->send()
The headers from the server. its not something we have control over its external
Cache-Control → private
Connection → close
Content-Encoding → gzip
Content-Length → 20
Content-Type → text/xml; charset=UTF-8
Date → Mon, 07 Dec 2015 09:30:02 GMT
Expires →
Expires
Gives the date/time after which the response is considered stale
Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified → Sun, 06 Dec 2015 09:58:06 GMT + 1
Pragma → public
Server → Apache
Vary → Accept-Encoding
X-Powered-By → PHP/5.3.23
the datetime headers differ because I've refetched the headers just now. But you see the spaces still being added.
One could argue that the header value is wrong and therefor it makes sense that the exception is thrown. The problem is that because of that exception, parsing of the the other headers stops so you can't do anything with the response anymore.
It seems to occur if you use $client->setStream($xyz);
This repository has been closed and moved to laminas/laminas-http; a new issue has been opened at https://github.com/laminas/laminas-http/issues/27.