HTTP server - URI handler return value
Posted: Sat Mar 30, 2024 7:31 pm
Hello,
I want to ask, what should be the return value of URI handlers?
Or rather, which errors from which functions should be forwarded, and what can be safely ignored?
Looking at the docs, I can see that only httpd_req_recv has this requirement:
However, in the examples the error is returned quite arbitrarily: ESP_ERR_NO_MEM, ESP_ERR_INVALID_ARG, ESP_FAIL, ESP_ERR_NOT_FOUND, possibly others.
Functions for sending data like httpd_resp_send are never checked for errors...
How does the returned value influence the working of the server?
I want to ask, what should be the return value of URI handlers?
Or rather, which errors from which functions should be forwarded, and what can be safely ignored?
Looking at the docs, I can see that only httpd_req_recv has this requirement:
If an error is returned, the URI handler must further return an error. This will ensure that the erroneous socket is closed and cleaned up by the web server.
However, in the examples the error is returned quite arbitrarily: ESP_ERR_NO_MEM, ESP_ERR_INVALID_ARG, ESP_FAIL, ESP_ERR_NOT_FOUND, possibly others.
Functions for sending data like httpd_resp_send are never checked for errors...
How does the returned value influence the working of the server?