|
If I send Zend\Http\Headers::addHeaders() an array containing multiple instances of the same header type (i.e. two complementary Cache-Control directives), the actual generated response keeps only the last instance of the header type. ZF1’s Zend_Controller_Response_Abstract::setHeader() method has the $replace parameter to explicitly control this behavior, but I couldn’t find a ZF2 equivalent. The documentation doesn’t seem to say anything explicit about this issue, and while I looked at code/unit tests and tried some experiments, I couldn’t find a solution that worked. Am I missing something? thanks, Demian |
|
Administrator
|
-- Demian Katz <[hidden email]> wrote
(on Thursday, 02 August 2012, 04:33 PM +0000): > If I send Zend\Http\Headers::addHeaders() an array containing multiple > instances of the same header type (i.e. two complementary Cache-Control > directives), the actual generated response keeps only the last instance of the > header type. Most likely, the Cache-Control header class is not implementing the MultipleHeaderInterface. > ZF1’s Zend_Controller_Response_Abstract::setHeader() method has the $replace > parameter to explicitly control this behavior, but I couldn’t find a ZF2 > equivalent. > > The documentation doesn’t seem to say anything explicit about this issue, and > while I looked at code/unit tests and tried some experiments, I couldn’t find a > solution that worked. > > Am I missing something? Nope -- it's a bug. -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc |
|
> Most likely, the Cache-Control header class is not implementing the
> MultipleHeaderInterface. Thanks -- I'll look into this and submit a PR if I can track down the problem. - Demian |
|
I spent a little time looking into this -- here's the test I wrote:
public function testMultipleCacheControlHeadersAreAllowed() { $headers = new Headers(); $headers->addHeaders( array( 'Cache-Control: no-cache', 'Cache-Control: no-store' ) ); $expected = array( 'Cache-Control' => array( 'no-cache', 'no-store' ) ); $result = $headers->toArray(); $this->assertEquals($expected, $result); } It fails because $headers->toArray returns array('Cache-Control' => 'no-store') rather than the two expected values. The Header\CacheControl class never even gets called. It looks like the Headers class never goes beyond processing the headers as strings. Unfortunately, I'm out of time to look into this right now -- I'm about to leave for a week's vacation. I can open a ticket when I get back if you think it's worthwhile. - Demian > -----Original Message----- > From: Demian Katz [mailto:[hidden email]] > Sent: Thursday, August 02, 2012 2:44 PM > To: Matthew Weier O'Phinney; [hidden email] > Subject: RE: [zf-contributors] Adding multiples of the same header in > Zend\Http\Headers > > > Most likely, the Cache-Control header class is not implementing the > > MultipleHeaderInterface. > > Thanks -- I'll look into this and submit a PR if I can track down the problem. > > - Demian |
| Powered by Nabble | Edit this page |
