mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-17 20:24:24 +00:00
httpd: create "connection" and "content-length" headers when file is ready
see patch #9500
This commit is contained in:
parent
e8d7e82c8c
commit
f7be3d10ae
@ -835,7 +835,6 @@ get_http_headers(struct http_state *hs, const char *uri)
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
char *ext;
|
char *ext;
|
||||||
char *vars;
|
char *vars;
|
||||||
u8_t add_content_len;
|
|
||||||
|
|
||||||
/* In all cases, the second header we send is the server identification
|
/* In all cases, the second header we send is the server identification
|
||||||
so set it here. */
|
so set it here. */
|
||||||
@ -929,7 +928,19 @@ get_http_headers(struct http_state *hs, const char *uri)
|
|||||||
/* No - use the default, plain text file type. */
|
/* No - use the default, plain text file type. */
|
||||||
hs->hdrs[HDR_STRINGS_IDX_CONTENT_TYPE] = HTTP_HDR_DEFAULT_TYPE;
|
hs->hdrs[HDR_STRINGS_IDX_CONTENT_TYPE] = HTTP_HDR_DEFAULT_TYPE;
|
||||||
}
|
}
|
||||||
/* Add content-length header? */
|
/* Set up to send the first header string. */
|
||||||
|
hs->hdr_index = 0;
|
||||||
|
hs->hdr_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add content-length header? */
|
||||||
|
static void
|
||||||
|
get_http_content_length(struct http_state *hs)
|
||||||
|
{
|
||||||
|
u8_t add_content_len = 0;
|
||||||
|
|
||||||
|
LWIP_ASSERT("already been here?", hs->hdrs[HDR_STRINGS_IDX_CONTENT_LEN_KEEPALIVE] == NULL);
|
||||||
|
|
||||||
add_content_len = 0;
|
add_content_len = 0;
|
||||||
#if LWIP_HTTPD_SSI
|
#if LWIP_HTTPD_SSI
|
||||||
if (hs->ssi == NULL) /* @todo: get maximum file length from SSI */
|
if (hs->ssi == NULL) /* @todo: get maximum file length from SSI */
|
||||||
@ -963,10 +974,6 @@ get_http_headers(struct http_state *hs, const char *uri)
|
|||||||
hs->hdrs[HDR_STRINGS_IDX_CONTENT_LEN_KEEPALIVE] = g_psHTTPHeaderStrings[HTTP_HDR_CONTENT_LENGTH];
|
hs->hdrs[HDR_STRINGS_IDX_CONTENT_LEN_KEEPALIVE] = g_psHTTPHeaderStrings[HTTP_HDR_CONTENT_LENGTH];
|
||||||
}
|
}
|
||||||
#endif /* LWIP_HTTPD_SUPPORT_11_KEEPALIVE */
|
#endif /* LWIP_HTTPD_SUPPORT_11_KEEPALIVE */
|
||||||
|
|
||||||
/* Set up to send the first header string. */
|
|
||||||
hs->hdr_index = 0;
|
|
||||||
hs->hdr_pos = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sub-function of http_send(): send dynamic headers
|
/** Sub-function of http_send(): send dynamic headers
|
||||||
@ -985,6 +992,11 @@ http_send_headers(struct altcp_pcb *pcb, struct http_state *hs)
|
|||||||
u8_t data_to_send = HTTP_NO_DATA_TO_SEND;
|
u8_t data_to_send = HTTP_NO_DATA_TO_SEND;
|
||||||
u16_t hdrlen, sendlen;
|
u16_t hdrlen, sendlen;
|
||||||
|
|
||||||
|
if (hs->hdrs[HDR_STRINGS_IDX_CONTENT_LEN_KEEPALIVE] == NULL) {
|
||||||
|
/* set up "content-length" and "connection:" headers */
|
||||||
|
get_http_content_length(hs);
|
||||||
|
}
|
||||||
|
|
||||||
/* How much data can we send? */
|
/* How much data can we send? */
|
||||||
len = altcp_sndbuf(pcb);
|
len = altcp_sndbuf(pcb);
|
||||||
sendlen = len;
|
sendlen = len;
|
||||||
|
Loading…
Reference in New Issue
Block a user