Setting Response to 404 has no effect

View: New views
3 Messages — Rating Filter:   Alert me  

Setting Response to 404 has no effect

by Robin Wyles :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

When I try to set the response code to 404 from within a generator it  
has no effect, i.e a 200 is still returned. It seems that  
HttpServletResponseBufferingWrapper[1] blocks this status code and  
doesn't set it on the wrapped HttpServletResponse.

Is this by design?

Thanks,

Robin

[1] http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon- 
servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/
cocoon/servletservice/HttpServletResponseBufferingWrapper.java?
view=markup




smime.p7s (3K) Download Attachment

Re: Setting Response to 404 has no effect

by solprovider-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 7/2/08, Robin Wyles <rob@...> wrote:

>  When I try to set the response code to 404 from within a generator it has
> no effect, i.e a 200 is still returned. It seems that
> HttpServletResponseBufferingWrapper[1] blocks this status
> code and doesn't set it on the wrapped HttpServletResponse.
>
>  Is this by design?
>
>  Thanks,
>  Robin
>
>  [1]
http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/HttpServletResponseBufferingWrapper.java?view=markup
===

Hi Robin,

I checked that a similar issue from before my time (Cocoon-2.1.6) and
fixed in Cocoon-2.1.11 does not apply to the 2.2.0 release.  The bug
http://issues.apache.org/bugzilla/show_bug.cgi?id=32336 has
disappeared from Bugzilla.  Understanding the process may help.

org.apache.cocoon.components.treeprocessor.sitemap.SerializeNodeBuilder
Resolves the status-code if a variable.  Creates SerializeNode.

org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode
Verifies status-code is an Integer.  Calls Environment.setStatus(int)

org.apache.cocoon.environment.Environment
wrapper for HttpEnvironment

org.apache.cocoon.environment.http.HttpEnvironment
Calls HttpResponse.setStatus(int)

HttpServletResponseBufferingWrapper implements this function with a
bypass based on isCommitted().  Try removing the bypass and see if the
status-code is set properly (for troubleshooting, not as a permanent
change.)

HTH,
solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Setting Response to 404 has no effect

by Robin Wyles :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Many thanks for the information - very useful. Turns out there seems  
to be an issue with C2.2 when setting the status of 404 inside  
map:handle-errors. This only occurs when setting the 404 in  
map:handle-errors and when the error is thrown inside a matcher.

Despite your explanation of the response handling process I still  
couldn't see why a 200 gets returned rather than the 404. It looked  
to me like ultimately the wrapped response did have its status code  
set to 404, and I couldn't find anywhere down the stack where it was  
changed or reset.

I've raised an issue on jira[1], along with a block that illustrates  
the issue if you're interested. Hopefully someone with more knowledge  
of Cocoon's internals will be able to take a look.

Thanks again,

Robin

[1] https://issues.apache.org/jira/browse/COCOON-2218

On 3 Jul 2008, at 01:36, solprovider@... wrote:

> On 7/2/08, Robin Wyles <rob@...> wrote:
>>  When I try to set the response code to 404 from within a  
>> generator it has
>> no effect, i.e a 200 is still returned. It seems that
>> HttpServletResponseBufferingWrapper[1] blocks this status
>> code and doesn't set it on the wrapped HttpServletResponse.
>>
>>  Is this by design?
>>
>>  Thanks,
>>  Robin
>>
>>  [1]
> http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon- 
> servlet-service/cocoon-servlet-service-impl/src/main/java/org/
> apache/cocoon/servletservice/
> HttpServletResponseBufferingWrapper.java?view=markup
> ===
>
> Hi Robin,
>
> I checked that a similar issue from before my time (Cocoon-2.1.6) and
> fixed in Cocoon-2.1.11 does not apply to the 2.2.0 release.  The bug
> http://issues.apache.org/bugzilla/show_bug.cgi?id=32336 has
> disappeared from Bugzilla.  Understanding the process may help.
>
> org.apache.cocoon.components.treeprocessor.sitemap.SerializeNodeBuilde
> r
> Resolves the status-code if a variable.  Creates SerializeNode.
>
> org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode
> Verifies status-code is an Integer.  Calls Environment.setStatus(int)
>
> org.apache.cocoon.environment.Environment
> wrapper for HttpEnvironment
>
> org.apache.cocoon.environment.http.HttpEnvironment
> Calls HttpResponse.setStatus(int)
>
> HttpServletResponseBufferingWrapper implements this function with a
> bypass based on isCommitted().  Try removing the bypass and see if the
> status-code is set properly (for troubleshooting, not as a permanent
> change.)
>
> HTH,
> solprovider
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


smime.p7s (3K) Download Attachment
LightInTheBox - Buy quality products at wholesale price