My next 2.1.0 problem: double response bodies

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

My next 2.1.0 problem: double response bodies

demiankatz
I'm running into a strange problem since upgrading to ZF 2.1.0.  I still need to do more investigation, but I thought I would describe it here in case it rings a bell and somebody can point me in the right direction.

It appears that JSON messages generated by my software are now getting doubled up -- i.e. the body is being output twice.  This is causing parsing problems and breaking Javascript functionality.  I've used wget to confirm that responses generated with ZF 2.1.0 are exactly twice as large as responses generated with ZF 2.0.6 when I make a request against the same URL.  This is only affecting my JSON messages -- HTML output through the rendering system isn't doubling up.

I have a controller [1] which generates JSON responses through a support method:
        protected function output($data, $status)
{
$response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine( 'Content-type', 'application/javascript' ); $headers->addHeaderLine( 'Cache-Control', 'no-cache, must-revalidate' ); $headers->addHeaderLine( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT' ); $output = array('data'=>$data,'status'=>$status); $response->setContent(json_encode($output)); return $response;
}
This seems pretty straightforward...  methods just build data and then "return $this->output($data, SOME_STATUS_CONSTANT);".

Am I misusing the framework somehow?  Any suggestions on which components or recent framework changes might be related to the problem so I can target my debugging efforts?  I'll put some more time into this tomorrow and report back with my findings... but any clues in the meantime would be much appreciated.

thanks,
Demian

[1] Full code here in case anyone is interested (not that I'm proud of this huge mess of unrelated functionality -- the separate AJAX controller is a relic of an earlier version of the software and needs to be factored away):  http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD
Reply | Threaded
Open this post in threaded view
|

RE: My next 2.1.0 problem: double response bodies

demiankatz
Thanks, Bas, that was it!

(Copying back to the list so that others can see this response).

What is the history of this?  I don't recall seeing anything about this in release notes, though it's always possible that I missed something.  It seems like there might be a lot of people innocently using earlier versions of the skeleton app who may be affected.

thanks,
Demian

From: Bas Kamer [[hidden email]]
Sent: Thursday, January 31, 2013 12:36 PM
To: Demian Katz
Subject: Re: [zf-contributors] My next 2.1.0 problem: double response bodies

Check that your index.php does not contain an ->send() after ->run()

Op 31 jan. 2013 om 18:28 heeft Demian Katz <[hidden email]> het volgende geschreven:

I'm running into a strange problem since upgrading to ZF 2.1.0.  I still need to do more investigation, but I thought I would describe it here in case it rings a bell and somebody can point me in the right direction.

It appears that JSON messages generated by my software are now getting doubled up -- i.e. the body is being output twice.  This is causing parsing problems and breaking Javascript functionality.  I've used wget to confirm that responses generated with ZF 2.1.0 are exactly twice as large as responses generated with ZF 2.0.6 when I make a request against the same URL.  This is only affecting my JSON messages -- HTML output through the rendering system isn't doubling up.

I have a controller [1] which generates JSON responses through a support method:
        protected function output($data, $status)
{
$response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine( 'Content-type', 'application/javascript' ); $headers->addHeaderLine( 'Cache-Control', 'no-cache, must-revalidate' ); $headers->addHeaderLine( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT' ); $output = array('data'=>$data,'status'=>$status); $response->setContent(json_encode($output)); return $response;
}
This seems pretty straightforward...  methods just build data and then "return $this->output($data, SOME_STATUS_CONSTANT);".

Am I misusing the framework somehow?  Any suggestions on which components or recent framework changes might be related to the problem so I can target my debugging efforts?  I'll put some more time into this tomorrow and report back with my findings... but any clues in the meantime would be much appreciated.

thanks,
Demian

[1] Full code here in case anyone is interested (not that I'm proud of this huge mess of unrelated functionality -- the separate AJAX controller is a relic of an earlier version of the software and needs to be factored away):  http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD
Reply | Threaded
Open this post in threaded view
|

Re: My next 2.1.0 problem: double response bodies

Sascha-Oliver Prolic
Hi Demian

sending responses is not part of the SendResponseListener and the corresponding Zend\Mvc\ResponseSender implementation.


2013/1/31 Demian Katz <[hidden email]>
Thanks, Bas, that was it!

(Copying back to the list so that others can see this response).

What is the history of this?  I don't recall seeing anything about this in release notes, though it's always possible that I missed something.  It seems like there might be a lot of people innocently using earlier versions of the skeleton app who may be affected.

thanks,
Demian

From: Bas Kamer [[hidden email]]
Sent: Thursday, January 31, 2013 12:36 PM
To: Demian Katz
Subject: Re: [zf-contributors] My next 2.1.0 problem: double response bodies

Check that your index.php does not contain an ->send() after ->run()

Op 31 jan. 2013 om 18:28 heeft Demian Katz <[hidden email]> het volgende geschreven:

I'm running into a strange problem since upgrading to ZF 2.1.0.  I still need to do more investigation, but I thought I would describe it here in case it rings a bell and somebody can point me in the right direction.

It appears that JSON messages generated by my software are now getting doubled up -- i.e. the body is being output twice.  This is causing parsing problems and breaking Javascript functionality.  I've used wget to confirm that responses generated with ZF 2.1.0 are exactly twice as large as responses generated with ZF 2.0.6 when I make a request against the same URL.  This is only affecting my JSON messages -- HTML output through the rendering system isn't doubling up.

I have a controller [1] which generates JSON responses through a support method:
        protected function output($data, $status)
{
$response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine( 'Content-type', 'application/javascript' ); $headers->addHeaderLine( 'Cache-Control', 'no-cache, must-revalidate' ); $headers->addHeaderLine( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT' ); $output = array('data'=>$data,'status'=>$status); $response->setContent(json_encode($output)); return $response;
}
This seems pretty straightforward...  methods just build data and then "return $this->output($data, SOME_STATUS_CONSTANT);".

Am I misusing the framework somehow?  Any suggestions on which components or recent framework changes might be related to the problem so I can target my debugging efforts?  I'll put some more time into this tomorrow and report back with my findings... but any clues in the meantime would be much appreciated.

thanks,
Demian

[1] Full code here in case anyone is interested (not that I'm proud of this huge mess of unrelated functionality -- the separate AJAX controller is a relic of an earlier version of the software and needs to be factored away):  http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD



--
Sascha-Oliver Prolic
Reply | Threaded
Open this post in threaded view
|

Re: My next 2.1.0 problem: double response bodies

Bas Kamer
In reply to this post by demiankatz
I have no idea where that came from. Just bumped my own nose on it once... :)

Op 31 jan. 2013 om 18:40 heeft Demian Katz <[hidden email]> het volgende geschreven:

Thanks, Bas, that was it!

(Copying back to the list so that others can see this response).

What is the history of this?  I don't recall seeing anything about this in release notes, though it's always possible that I missed something.  It seems like there might be a lot of people innocently using earlier versions of the skeleton app who may be affected.

thanks,
Demian

From: Bas Kamer [[hidden email]]
Sent: Thursday, January 31, 2013 12:36 PM
To: Demian Katz
Subject: Re: [zf-contributors] My next 2.1.0 problem: double response bodies

Check that your index.php does not contain an ->send() after ->run()

Op 31 jan. 2013 om 18:28 heeft Demian Katz <[hidden email]> het volgende geschreven:

I'm running into a strange problem since upgrading to ZF 2.1.0.  I still need to do more investigation, but I thought I would describe it here in case it rings a bell and somebody can point me in the right direction.

It appears that JSON messages generated by my software are now getting doubled up -- i.e. the body is being output twice.  This is causing parsing problems and breaking Javascript functionality.  I've used wget to confirm that responses generated with ZF 2.1.0 are exactly twice as large as responses generated with ZF 2.0.6 when I make a request against the same URL.  This is only affecting my JSON messages -- HTML output through the rendering system isn't doubling up.

I have a controller [1] which generates JSON responses through a support method:
        protected function output($data, $status)
{
$response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine( 'Content-type', 'application/javascript' ); $headers->addHeaderLine( 'Cache-Control', 'no-cache, must-revalidate' ); $headers->addHeaderLine( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT' ); $output = array('data'=>$data,'status'=>$status); $response->setContent(json_encode($output)); return $response;
}
This seems pretty straightforward...  methods just build data and then "return $this->output($data, SOME_STATUS_CONSTANT);".

Am I misusing the framework somehow?  Any suggestions on which components or recent framework changes might be related to the problem so I can target my debugging efforts?  I'll put some more time into this tomorrow and report back with my findings... but any clues in the meantime would be much appreciated.

thanks,
Demian

[1] Full code here in case anyone is interested (not that I'm proud of this huge mess of unrelated functionality -- the separate AJAX controller is a relic of an earlier version of the software and needs to be factored away):  http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD
Reply | Threaded
Open this post in threaded view
|

Re: My next 2.1.0 problem: double response bodies

Marco Pivetta
This post has NOT been accepted by the mailing list yet.
Well, it was responsibility of the SendResponseListener. Now the SendResponseListener is just an aggregate of other listeners that act in different environments :)



On 31 January 2013 18:43, Bas Kamer [via Zend Framework Community] <[hidden email]> wrote:
I have no idea where that came from. Just bumped my own nose on it once... :)

Op 31 jan. 2013 om 18:40 heeft Demian Katz <[hidden email]> het volgende geschreven:

Thanks, Bas, that was it!

(Copying back to the list so that others can see this response).

What is the history of this?  I don't recall seeing anything about this in release notes, though it's always possible that I missed something.  It seems like there might be a lot of people innocently using earlier versions of the skeleton app who may be affected.

thanks,
Demian

From: Bas Kamer [[hidden email]]

Sent: Thursday, January 31, 2013 12:36 PM
To: Demian Katz
Subject: Re: [zf-contributors] My next 2.1.0 problem: double response bodies

Check that your index.php does not contain an ->send() after ->run()

Op 31 jan. 2013 om 18:28 heeft Demian Katz <[hidden email]> het volgende geschreven:

I'm running into a strange problem since upgrading to ZF 2.1.0.  I still need to do more investigation, but I thought I would describe it here in case it rings a bell and somebody can point me in the right direction.

It appears that JSON messages generated by my software are now getting doubled up -- i.e. the body is being output twice.  This is causing parsing problems and breaking Javascript functionality.  I've used wget to confirm that responses generated with ZF 2.1.0 are exactly twice as large as responses generated with ZF 2.0.6 when I make a request against the same URL.  This is only affecting my JSON messages -- HTML output through the rendering system isn't doubling up.

I have a controller [1] which generates JSON responses through a support method:
        protected function output($data, $status)
{
$response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine( 'Content-type', 'application/javascript' ); $headers->addHeaderLine( 'Cache-Control', 'no-cache, must-revalidate' ); $headers->addHeaderLine( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT' ); $output = array('data'=>$data,'status'=>$status); $response->setContent(json_encode($output)); return $response;
}
This seems pretty straightforward...  methods just build data and then "return $this->output($data, SOME_STATUS_CONSTANT);".

Am I misusing the framework somehow?  Any suggestions on which components or recent framework changes might be related to the problem so I can target my debugging efforts?  I'll put some more time into this tomorrow and report back with my findings... but any clues in the meantime would be much appreciated.

thanks,
Demian

[1] Full code here in case anyone is interested (not that I'm proud of this huge mess of unrelated functionality -- the separate AJAX controller is a relic of an earlier version of the software and needs to be factored away):  http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD



If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/My-next-2-1-0-problem-double-response-bodies-tp4658901p4658904.html
To start a new topic under ZF Contributor, email [hidden email]
To unsubscribe from ZF Contributor, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: My next 2.1.0 problem: double response bodies

weierophinney
Administrator
In reply to this post by demiankatz
On Thu, Jan 31, 2013 at 11:40 AM, Demian Katz <[hidden email]> wrote:
> Thanks, Bas, that was it!
>
> (Copying back to the list so that others can see this response).
>
> What is the history of this?  I don't recall seeing anything about this in
> release notes, though it's always possible that I missed something.  It
> seems like there might be a lot of people innocently using earlier versions
> of the skeleton app who may be affected.

We actually pushed a change around two weeks ago that should have made
that a moot point. Basically, the Application object now returns
itself from run(), and defines a "send()" method that does nothing.
This was to allow the old skeleton app structure to work correctly.

However... in looking at the code, I see a place we missed. There are
some paths in run() that end up calling "return
$this->completeRequest($event);" -- and that returns a response
object.

I'll get this fixed on master today, so it can be fixed for the 2.1.1 release.

_____________________________

> From: Bas Kamer [[hidden email]]
> Sent: Thursday, January 31, 2013 12:36 PM
> To: Demian Katz
> Subject: Re: [zf-contributors] My next 2.1.0 problem: double response bodies
>
> Check that your index.php does not contain an ->send() after ->run()
>
> Op 31 jan. 2013 om 18:28 heeft Demian Katz <[hidden email]> het
> volgende geschreven:
>
> I'm running into a strange problem since upgrading to ZF 2.1.0.  I still
> need to do more investigation, but I thought I would describe it here in
> case it rings a bell and somebody can point me in the right direction.
>
> It appears that JSON messages generated by my software are now getting
> doubled up -- i.e. the body is being output twice.  This is causing parsing
> problems and breaking Javascript functionality.  I've used wget to confirm
> that responses generated with ZF 2.1.0 are exactly twice as large as
> responses generated with ZF 2.0.6 when I make a request against the same
> URL.  This is only affecting my JSON messages -- HTML output through the
> rendering system isn't doubling up.
>
> I have a controller [1] which generates JSON responses through a support
> method:
>
>         protected function output($data, $status)
>         {
>             $response = $this->getResponse();
>             $headers = $response->getHeaders();
>             $headers->addHeaderLine(
>                 'Content-type', 'application/javascript'
>             );
>             $headers->addHeaderLine(
>                 'Cache-Control', 'no-cache, must-revalidate'
>             );
>             $headers->addHeaderLine(
>                 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'
>             );
>             $output = array('data'=>$data,'status'=>$status);
>             $response->setContent(json_encode($output));
>             return $response;
>         }
>
> This seems pretty straightforward...  methods just build data and then
> "return $this->output($data, SOME_STATUS_CONSTANT);".
>
> Am I misusing the framework somehow?  Any suggestions on which components or
> recent framework changes might be related to the problem so I can target my
> debugging efforts?  I'll put some more time into this tomorrow and report
> back with my findings... but any clues in the meantime would be much
> appreciated.
>
> thanks,
> Demian
>
> [1] Full code here in case anyone is interested (not that I'm proud of this
> huge mess of unrelated functionality -- the separate AJAX controller is a
> relic of an earlier version of the software and needs to be factored away):
> http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD



--
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
Reply | Threaded
Open this post in threaded view
|

Re: My next 2.1.0 problem: double response bodies

weierophinney
Administrator
On Fri, Feb 1, 2013 at 10:42 AM, Matthew Weier O'Phinney
<[hidden email]> wrote:

> On Thu, Jan 31, 2013 at 11:40 AM, Demian Katz <[hidden email]> wrote:
>> Thanks, Bas, that was it!
>>
>> (Copying back to the list so that others can see this response).
>>
>> What is the history of this?  I don't recall seeing anything about this in
>> release notes, though it's always possible that I missed something.  It
>> seems like there might be a lot of people innocently using earlier versions
>> of the skeleton app who may be affected.
>
> We actually pushed a change around two weeks ago that should have made
> that a moot point. Basically, the Application object now returns
> itself from run(), and defines a "send()" method that does nothing.
> This was to allow the old skeleton app structure to work correctly.
>
> However... in looking at the code, I see a place we missed. There are
> some paths in run() that end up calling "return
> $this->completeRequest($event);" -- and that returns a response
> object.
>
> I'll get this fixed on master today, so it can be fixed for the 2.1.1 release.

The PR is in: https://github.com/zendframework/zf2/pull/3648

__________________________

>> From: Bas Kamer [[hidden email]]
>> Sent: Thursday, January 31, 2013 12:36 PM
>> To: Demian Katz
>> Subject: Re: [zf-contributors] My next 2.1.0 problem: double response bodies
>>
>> Check that your index.php does not contain an ->send() after ->run()
>>
>> Op 31 jan. 2013 om 18:28 heeft Demian Katz <[hidden email]> het
>> volgende geschreven:
>>
>> I'm running into a strange problem since upgrading to ZF 2.1.0.  I still
>> need to do more investigation, but I thought I would describe it here in
>> case it rings a bell and somebody can point me in the right direction.
>>
>> It appears that JSON messages generated by my software are now getting
>> doubled up -- i.e. the body is being output twice.  This is causing parsing
>> problems and breaking Javascript functionality.  I've used wget to confirm
>> that responses generated with ZF 2.1.0 are exactly twice as large as
>> responses generated with ZF 2.0.6 when I make a request against the same
>> URL.  This is only affecting my JSON messages -- HTML output through the
>> rendering system isn't doubling up.
>>
>> I have a controller [1] which generates JSON responses through a support
>> method:
>>
>>         protected function output($data, $status)
>>         {
>>             $response = $this->getResponse();
>>             $headers = $response->getHeaders();
>>             $headers->addHeaderLine(
>>                 'Content-type', 'application/javascript'
>>             );
>>             $headers->addHeaderLine(
>>                 'Cache-Control', 'no-cache, must-revalidate'
>>             );
>>             $headers->addHeaderLine(
>>                 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'
>>             );
>>             $output = array('data'=>$data,'status'=>$status);
>>             $response->setContent(json_encode($output));
>>             return $response;
>>         }
>>
>> This seems pretty straightforward...  methods just build data and then
>> "return $this->output($data, SOME_STATUS_CONSTANT);".
>>
>> Am I misusing the framework somehow?  Any suggestions on which components or
>> recent framework changes might be related to the problem so I can target my
>> debugging efforts?  I'll put some more time into this tomorrow and report
>> back with my findings... but any clues in the meantime would be much
>> appreciated.
>>
>> thanks,
>> Demian
>>
>> [1] Full code here in case anyone is interested (not that I'm proud of this
>> huge mess of unrelated functionality -- the separate AJAX controller is a
>> relic of an earlier version of the software and needs to be factored away):
>> http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob_plain;f=module/VuFind/src/VuFind/Controller/AjaxController.php;hb=HEAD
>
>
>
> --
> 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



--
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