Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Zend\Http\Response should treat 410 like a not found #72

Open
GeeH opened this issue Jun 28, 2016 · 1 comment
Open

Zend\Http\Response should treat 410 like a not found #72

GeeH opened this issue Jun 28, 2016 · 1 comment

Comments

@GeeH
Copy link
Contributor

GeeH commented Jun 28, 2016

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7368
User: @coogle
Created On: 2015-03-26T00:03:33Z
Updated At: 2015-03-26T15:09:34Z
Body
According to RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) A server has the option of returning a HTTP 410 status code when a resource is not found and moreover the server understands the resource will never return (gone).

From a ZF perspective, it seems to me that the Response::isNotFound() method should return true in this case, and at present it does not. A 410 is a 404, with more insight into the status of the resource.


Comment

User: @Martin-P
Created On: 2015-03-26T13:29:04Z
Updated At: 2015-03-26T13:29:04Z
Body
Sounds like a bad idea IMHO. I understand a 410 can be interpreted as a 404, but is fundamentally different. A 410 indicates the resource existed once and is gone now, a 404 however indicates a resource that was never there at all. Furthermore the term "Not found" is always used in a 404 context, because it is the phrase that belongs to a 404 status code. When you add a 410 to the same description "Not found" (in ZF) you create confusion, because the term which was meant for one specific response code (404) is suddenly used for multiple response codes (404 and 410).

As a compromise a new method isGone() looks like a clean solution to me. That way you can make it easier if someone wants to check if a resource is gone.


Comment

User: @macnibblet
Created On: 2015-03-26T13:33:37Z
Updated At: 2015-03-26T13:33:37Z
Body
I agree with @Martin-P because frankly they are two different things and if the api is so advanced it supports 410 then you should be looking for that specifically.

This is also not that complicated

if ($response->isNotFound() || $response->isGone()) 

Comment

User: @coogle
Created On: 2015-03-26T15:09:34Z
Updated At: 2015-03-26T15:09:34Z
Body
It's not that "can be interpreted" is a 404, the RFC Specifically states that if the server knows the resource was there and is gone it should return 410. 404 Does NOT mean the resource was never there at all, just that simply it cannot find anything at the moment -- they are not two different things but simply the same thing with more detail.

404

The server has not found anything matching the Request-URI. No indication is given of whether the
condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server
knows, through some internally configurable mechanism, that an old resource is permanently
unavailable and has no forwarding address. This status code is commonly used when the server does > not wish to reveal exactly why the request has been refused, or when no other response is applicable.

I will be personally satisfied with an isGone(), but I disagree that isNotFound() returning true on a 404 OR a 410 is somehow confusing or broken behavior. The RFC is pretty explicit on the issue, and the argument that users will be confused when as it was pointed out that this is an "advanced case" is pretty flimsy to me.


@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-http; a new issue has been opened at laminas/laminas-http#11.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants