itead / Sonoff_Devices_DIY_Tools

BSD 3-Clause "New" or "Revised" License
548 stars 168 forks source link

Please use HTTP protocol specs #55

Closed frenck closed 4 years ago

frenck commented 4 years ago

The firmware currently always returns HTTP 200 (unless it is not responsive, in that case, nothing of course).

This is weird and incorrect IMHO. If there is something wrong with the request, the returned HTTP status code should reflect that.

Right now, one has to build custom error handling because of this, while normally one should be able to rely on HTTP specs.

For example:

image

This is a non-existing URL, while the API throws an error 422 in the response JSON; it should have thrown an HTTP 404 status code (since it does not exists).

Same for invalid data and other things once would expect a 400 or higher HTTP response code.

Daniel-zhan-itead commented 4 years ago

Sonoff will correct this in the next firmware

frenck commented 4 years ago

Great! 👍

Daniel-zhan-itead commented 4 years ago

issue has been fixed in the new firmware

frenck commented 4 years ago

Awesome! Thanks 👍