mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-05 08:28:32 +00:00
http_client: check current state when receiving FIN
This commit is contained in:
parent
91a2d9e237
commit
b6d9bb6b2a
@ -280,7 +280,19 @@ httpc_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t r)
|
||||
LWIP_UNUSED_ARG(r);
|
||||
|
||||
if (p == NULL) {
|
||||
return httpc_close(req, HTTPC_RESULT_OK, req->rx_status, ERR_OK);
|
||||
httpc_result_t result;
|
||||
if (req->parse_state != HTTPC_PARSE_RX_DATA) {
|
||||
/* did not get RX data yet */
|
||||
result = HTTPC_RESULT_ERR_CLOSED;
|
||||
} else if ((req->hdr_content_len != HTTPC_CONTENT_LEN_INVALID) &&
|
||||
(req->hdr_content_len != req->rx_content_len)) {
|
||||
/* header has been received with content length but not all data received */
|
||||
result = HTTPC_RESULT_ERR_CONTENT_LEN;
|
||||
} else {
|
||||
/* receiving data and either all data received or no content length header */
|
||||
result = HTTPC_RESULT_OK;
|
||||
}
|
||||
return httpc_close(req, result, req->rx_status, ERR_OK);
|
||||
}
|
||||
if (req->parse_state != HTTPC_PARSE_RX_DATA) {
|
||||
if (req->rx_hdrs == NULL) {
|
||||
|
@ -86,7 +86,9 @@ typedef enum ehttpc_result {
|
||||
/** Local memory error */
|
||||
HTTPC_RESULT_ERR_MEM = 7,
|
||||
/** Local abort */
|
||||
HTTPC_RESULT_LOCAL_ABORT = 8
|
||||
HTTPC_RESULT_LOCAL_ABORT = 8,
|
||||
/** Content length mismatch */
|
||||
HTTPC_RESULT_ERR_CONTENT_LEN = 9
|
||||
} httpc_result_t;
|
||||
|
||||
typedef struct _httpc_state httpc_state_t;
|
||||
|
Loading…
Reference in New Issue
Block a user