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

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

Closed
coogle opened this issue Mar 26, 2015 · 4 comments
Closed

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

coogle opened this issue Mar 26, 2015 · 4 comments
Labels

Comments

@coogle
Copy link

coogle commented Mar 26, 2015

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.

@Martin-P
Copy link
Contributor

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.

@macnibblet
Copy link
Contributor

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

@coogle
Copy link
Author

coogle commented Mar 26, 2015

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.

asgrim added a commit to asgrim/zend-http that referenced this issue Jun 6, 2015
As per the discussion in zendframework/zendframework#7368 this change adds a new
method \Zend\Http\Response->isGone() to determine if the status code is
a "410 Gone". This works exactly the same as the similar methods like
isNotFound simply by checking the status code.

This change takes the opinion that a 410 Gone should not be included in
the isNotFound() method. Further discussion can be seen in the issue.
asgrim added a commit to asgrim/zend-http that referenced this issue Jul 19, 2015
As per the discussion in zendframework/zendframework#7368 this change adds a new
method \Zend\Http\Response->isGone() to determine if the status code is
a "410 Gone". This works exactly the same as the similar methods like
isNotFound simply by checking the status code.

This change takes the opinion that a 410 Gone should not be included in
the isNotFound() method. Further discussion can be seen in the issue.
@GeeH
Copy link

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
New issue can be found at: zendframework/zend-http#72

@GeeH GeeH closed this as completed Jun 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants