mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
http: server: support HEAD via mount
Until now we parse HEAD requests but don't properly fulfil them. This adds enough that if the request pointed to a valid mount, it will send the headers and complete the transaction without sending the body. Test with $ (echo -n -e "GET / HTTP/1.0\r\nHost: default\r\n\r\n"; sleep 2) | nc 127.0.0.1 7681
This commit is contained in:
parent
4e7cefb006
commit
a60e60bc29
1 changed files with 9 additions and 0 deletions
|
@ -767,6 +767,7 @@ lws_find_mount(struct lws *wsi, const char *uri_ptr, int uri_len)
|
|||
((hm->origin_protocol == LWSMPRO_CGI ||
|
||||
lws_hdr_total_length(wsi, WSI_TOKEN_GET_URI) ||
|
||||
lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI) ||
|
||||
lws_hdr_total_length(wsi, WSI_TOKEN_HEAD_URI) ||
|
||||
(wsi->http2_substream &&
|
||||
lws_hdr_total_length(wsi,
|
||||
WSI_TOKEN_HTTP_COLON_PATH)) ||
|
||||
|
@ -2564,6 +2565,14 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,
|
|||
wsi->http.filepos = 0;
|
||||
lwsi_set_state(wsi, LRS_ISSUING_FILE);
|
||||
|
||||
if (lws_hdr_total_length(wsi, WSI_TOKEN_HEAD_URI)) {
|
||||
/* we do not emit the body */
|
||||
if (lws_http_transaction_completed(wsi))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
lws_callback_on_writable(wsi);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue