MT#56447 support HTTP OPTIONS

Rudimentary dummy response only

Change-Id: I753a0fddcd1e089f4be11c2d516f540adf459fea
pull/1611/head
Richard Fuchs 3 years ago
parent 4697b437d5
commit 9b20ce2ef9

@ -549,6 +549,24 @@ static int websocket_http_post(struct websocket_conn *wc) {
}
static const char *websocket_http_options_generic(struct websocket_message *wm) {
ilogs(http, LOG_DEBUG, "Respoding to OPTIONS");
return websocket_http_complete(wm->wc, 200, NULL, 0, NULL);
}
static int websocket_http_options(struct websocket_conn *wc) {
struct websocket_message *wm = wc->wm;
ilogs(http, LOG_INFO, "HTTP OPTIONS from %s: '%s'", endpoint_print_buf(&wc->endpoint), wm->uri);
wm->method = M_OPTIONS;
websocket_message_push(wc, websocket_http_options_generic);
return 0;
}
static int websocket_http_body(struct websocket_conn *wc, const char *body, size_t len) {
struct websocket_message *wm = wc->wm;
const char *uri = wm->uri;
@ -700,6 +718,8 @@ static int websocket_do_http(struct lws *wsi, struct websocket_conn *wc, const c
return websocket_http_get(wc);
if (lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI))
return websocket_http_post(wc);
if (lws_hdr_total_length(wsi, WSI_TOKEN_OPTIONS_URI))
return websocket_http_options(wc);
ilogs(http, LOG_INFO, "Ignoring HTTP request to %s with unsupported method", uri);
return 0;

@ -21,6 +21,7 @@ struct websocket_message {
M_WEBSOCKET,
M_GET,
M_POST,
M_OPTIONS,
} method;
enum {
CT_UNKNOWN = 0,

Loading…
Cancel
Save