Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

HTTP 404 uses HTML instead of JSON #756

Closed
steffenweber opened this issue Dec 2, 2016 · 1 comment
Closed

HTTP 404 uses HTML instead of JSON #756

steffenweber opened this issue Dec 2, 2016 · 1 comment
Assignees
Labels

Comments

@steffenweber
Copy link

steffenweber commented Dec 2, 2016

Sending a push request to a non-existing endpoint URL causes a 404 response (as expected). But this response should use the Content-Type JSON instead of HTML. How to reproduce:

$ curl -v --data '' https://updates.push.services.mozilla.com/push/v1/foo
> POST /push/v1/foo HTTP/1.1
> Host: updates.push.services.mozilla.com
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 404 Not Found
< Content-Type: text/html; charset=UTF-8
< Date: Fri, 02 Dec 2016 08:24:00 GMT
< Content-Length: 69
< Connection: keep-alive
< 
<html><title>404: Not Found</title><body>404: Not Found</body></html>
@ghost ghost self-assigned this Dec 2, 2016
ghost pushed a commit that referenced this issue Dec 2, 2016
Tip-of-tree fiorix/cyclone supports custom error handlers via an
`error_handler` argument to `cyclone.web.Application`, but that hasn't
been published to PyPI yet. We work around this by registering a
catch-all handler that returns a 404 instead.

Closes #756.
@collimarco
Copy link

+1 For this

Moreover consider adding an errno to the JSON.
Based on your docs it should be "errno 102 - Invalid URL endpoint": I would use that for a double check before deleting the endpoint from the app server. If I get a 404 I also check the errno: if it's equal to 102 then delete the endpoint otherwise do nothing (this is because I fear that your server may return a 404 for other / temporary reasons).

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

4 participants