HTTP Server : Bug fixed in httpd_recv logic and updated function descriptions

This commit is contained in:
Anurag Kar
2018-10-09 17:54:33 +05:30
parent 7e04e283d5
commit 30632c0c34
2 changed files with 12 additions and 2 deletions

View File

@@ -378,6 +378,7 @@ typedef int (*httpd_send_func_t)(int sockfd, const char *buf, size_t buf_len, in
* *
* @return * @return
* - Bytes : The number of bytes received successfully * - Bytes : The number of bytes received successfully
* - 0 : Buffer length parameter is zero / connection closed by peer
* - HTTPD_SOCK_ERR_INVALID : Invalid arguments * - HTTPD_SOCK_ERR_INVALID : Invalid arguments
* - HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket recv() * - HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket recv()
* - HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket recv() * - HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket recv()
@@ -481,7 +482,7 @@ int httpd_req_to_sockfd(httpd_req_t *r);
* *
* @return * @return
* - Bytes : Number of bytes read into the buffer successfully * - Bytes : Number of bytes read into the buffer successfully
* - Zero : When no more data is left for read * - 0 : Buffer length parameter is zero / connection closed by peer
* - HTTPD_SOCK_ERR_INVALID : Invalid arguments * - HTTPD_SOCK_ERR_INVALID : Invalid arguments
* - HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket recv() * - HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket recv()
* - HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket recv() * - HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket recv()

View File

@@ -128,6 +128,15 @@ int httpd_recv_with_opt(httpd_req_t *r, char *buf, size_t buf_len, bool halt_aft
int ret = ra->sd->recv_fn(ra->sd->fd, buf, buf_len, 0); int ret = ra->sd->recv_fn(ra->sd->fd, buf, buf_len, 0);
if (ret < 0) { if (ret < 0) {
ESP_LOGD(TAG, LOG_FMT("error in recv_fn")); ESP_LOGD(TAG, LOG_FMT("error in recv_fn"));
if ((ret == HTTPD_SOCK_ERR_TIMEOUT) && (pending_len != 0)) {
/* If recv() timeout occurred, but pending data is
* present, return length of pending data.
* This behavior is similar to that of socket recv()
* function, which, in case has only partially read the
* requested length, due to timeout, returns with read
* length, rather than error */
return pending_len;
}
return ret; return ret;
} }