Forwarding Response and Content Negotiation Feauture

15 views
Skip to first unread message

Josh Lockhart

unread,
Jun 22, 2009, 1:59:40 PM6/22/09
to recess-f...@googlegroups.com
Hi Everyone,

I have installed Recess edge from GitHub upgrading from the previous version of Recess. However, I have run into a new issue. With the previous version of Recess, in a controller method I called this code:

return $this->found($this->urlTo('someMethod'));

This code would successfully create a ForwardingResponse, set the Location header, and the browser would correctly display the template for someMethod. However, after upgrading to Recess edge with the new content negotiation feature, Recess is rendering the template for the method that calls the above code instead of forwarding to someMethod as it should. Am I doing something wrong? Or is this how it is supposed to work?

Thanks for your help!
Josh

--
Josh Lockhart
Web Developer, New Media Campaigns
http://www.newmediacampaigns.com
Email: jo...@newmediacampaigns.com

Kris Jordan

unread,
Jun 22, 2009, 2:22:03 PM6/22/09
to recess-f...@googlegroups.com
Josh,

In what context are you using the Found response?

Found isn't a subclass of ForwardingResponse so it doesn't automatically 'forward' a request to use the Location's content as the body. This is as opposed to CreatedResponse which does forward and is a subclass of ForwardingResponse.

The purpose of the Found response is to indicate a temporary redirect (and one that browsers should prompt you before taking, according to HTTP spec). If this is your intention and you want it to forward I would create a new ForwardingFound class that subclasses ForwardingResponse. Use CreatedResponse as the template.

Kris

Joshua Paine

unread,
Jun 22, 2009, 2:58:17 PM6/22/09
to recess-f...@googlegroups.com
Josh,

I ran into this issue with pre-content negotiation Recess. Turns out
that since some time Recess would set the headers correctly but also
load the template and make that the response body. In general that
didn't matter, and even an error wouldn't cause a user-perceivable
problem b/c the browser never displays the body of a FOUND redirect.
Part of the problem turned out to be that I had a blank line at the end
of my recess.conf, causing the headers to be sent early--and the chunk
of Recess that sets the headers for a FOUND response (and others) was
wrapped in if(!headers_sent()), so it would just fail silently. Talked
with Kris about making that fail loudly, but I don't know if he got to
changing it yet.

In some cases even with the blank line removed, Recess still gave me
trouble when it couldn't find a view for a FOUND response. I ended up
adding 301 and 302 to the internal list of responses for which there
should be no body. This is not correct according to RFC, but in my
practical experience it is always correct.

--
Joshua Paine
LetterBlock: Web applications built with joy
http://letterblock.com/
301-576-1920

Josh Lockhart

unread,
Jun 22, 2009, 5:17:46 PM6/22/09
to recess-f...@googlegroups.com
Kris,

Thanks for the suggestions. It seems that $this->found() is not what I need. However, even when I switch to $this->forwardOk($this->urlTo('someMethod')) the same problem occurs. I removed blank white space in my Recess configuration file per Joshua Paine's suggestions, but the problem remains. Ideas?

Josh

--
Josh Lockhart
Web Developer, New Media Campaigns
http://www.newmediacampaigns.com
Email: jo...@newmediacampaigns.com


Reply all
Reply to author
Forward
0 new messages