mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-06-11 09:29:40 +00:00
For LWIP_HTTPD_DYNAMIC_HEADERS==1, skip get_http_headers() if http_header_included
This commit is contained in:
parent
6962ff18d8
commit
6bb0cded4f
|
@ -96,6 +96,7 @@ fs_open(const char *name)
|
||||||
file->len = f->len;
|
file->len = f->len;
|
||||||
file->index = f->len;
|
file->index = f->len;
|
||||||
file->pextension = NULL;
|
file->pextension = NULL;
|
||||||
|
file->http_header_included = f->http_header_included;
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct fs_file {
|
||||||
int len;
|
int len;
|
||||||
int index;
|
int index;
|
||||||
void *pextension;
|
void *pextension;
|
||||||
|
int http_header_included;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* file must be allocated by caller and will be filled in
|
/* file must be allocated by caller and will be filled in
|
||||||
|
|
|
@ -632,7 +632,7 @@ http_send_data(struct tcp_pcb *pcb, struct http_state *hs)
|
||||||
/* We don't have a send buffer so allocate one up to 2mss bytes long. */
|
/* We don't have a send buffer so allocate one up to 2mss bytes long. */
|
||||||
count = 2 * pcb->mss;
|
count = 2 * pcb->mss;
|
||||||
do {
|
do {
|
||||||
hs->buf = mem_malloc((mem_size_t)count);
|
hs->buf = (char*)mem_malloc((mem_size_t)count);
|
||||||
if (hs->buf != NULL) {
|
if (hs->buf != NULL) {
|
||||||
hs->buf_len = count;
|
hs->buf_len = count;
|
||||||
break;
|
break;
|
||||||
|
@ -1265,7 +1265,9 @@ http_parse_request(struct pbuf *p, struct http_state *hs)
|
||||||
#if LWIP_HTTPD_DYNAMIC_HEADERS
|
#if LWIP_HTTPD_DYNAMIC_HEADERS
|
||||||
/* Determine the HTTP headers to send based on the file extension of
|
/* Determine the HTTP headers to send based on the file extension of
|
||||||
* the requested URI. */
|
* the requested URI. */
|
||||||
get_http_headers(hs, uri);
|
if (!hs->handle->http_header_included) {
|
||||||
|
get_http_headers(hs, uri);
|
||||||
|
}
|
||||||
#endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
|
#endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
|
||||||
} else {
|
} else {
|
||||||
/* @todo: return HTTP error 501 */
|
/* @todo: return HTTP error 501 */
|
||||||
|
@ -1298,28 +1300,20 @@ http_err(void *arg, err_t err)
|
||||||
static err_t
|
static err_t
|
||||||
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
|
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||||
{
|
{
|
||||||
struct http_state *hs;
|
struct http_state *hs = (struct http_state *)arg;
|
||||||
|
|
||||||
LWIP_DEBUGF(HTTPD_DEBUG, ("http_sent %p\n", (void*)pcb));
|
LWIP_DEBUGF(HTTPD_DEBUG, ("http_sent %p\n", (void*)pcb));
|
||||||
|
|
||||||
LWIP_UNUSED_ARG(len);
|
LWIP_UNUSED_ARG(len);
|
||||||
|
|
||||||
if(!arg) {
|
if (hs == NULL) {
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
hs = arg;
|
|
||||||
|
|
||||||
hs->retries = 0;
|
hs->retries = 0;
|
||||||
|
|
||||||
/* Temporarily disable send notifications */
|
|
||||||
tcp_sent(pcb, NULL);
|
|
||||||
|
|
||||||
http_send_data(pcb, hs);
|
http_send_data(pcb, hs);
|
||||||
|
|
||||||
/* Reenable notifications. */
|
|
||||||
tcp_sent(pcb, http_sent);
|
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user