mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
http: mounts: LWSMPRO_NO_MOUNT
Provide a way to apply exception mount urls that exist on top of a larger mount, but provide an exception which enforces the url to not be serviced by the mount code, but by whatever dynamic handler is in place.
This commit is contained in:
parent
5e43b7039c
commit
957503436e
6 changed files with 24 additions and 1 deletions
|
@ -1294,7 +1294,8 @@ enum lws_mount_protocols {
|
|||
LWSMPRO_CGI = 3, /**< pass to CGI to handle */
|
||||
LWSMPRO_REDIR_HTTP = 4, /**< redirect to http:// url */
|
||||
LWSMPRO_REDIR_HTTPS = 5, /**< redirect to https:// url */
|
||||
LWSMPRO_CALLBACK = 6, /**< hand by named protocol's callback */
|
||||
LWSMPRO_CALLBACK = 6, /**< handle by named protocol's callback */
|
||||
LWSMPRO_NO_MOUNT = 7, /**< matches fall back to no match processing */
|
||||
};
|
||||
|
||||
/** enum lws_authentication_mode
|
||||
|
@ -1357,5 +1358,8 @@ struct lws_http_mount {
|
|||
*/
|
||||
};
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN void
|
||||
lws_vhost_set_mounts(struct lws_vhost *v, const struct lws_http_mount *mounts);
|
||||
|
||||
///@}
|
||||
///@}
|
||||
|
|
|
@ -120,6 +120,7 @@ __lws_reset_wsi(struct lws *wsi)
|
|||
}
|
||||
#endif
|
||||
wsi->retry = 0;
|
||||
wsi->mount_hit = 0;
|
||||
|
||||
#if defined(LWS_WITH_CLIENT)
|
||||
lws_dll2_remove(&wsi->dll2_cli_txn_queue);
|
||||
|
|
|
@ -812,6 +812,7 @@ struct lws {
|
|||
unsigned int file_desc:1;
|
||||
unsigned int conn_validity_wakesuspend:1;
|
||||
unsigned int dns_reachability:1;
|
||||
unsigned int mount_hit:1;
|
||||
|
||||
unsigned int could_have_pending:1; /* detect back-to-back writes */
|
||||
unsigned int outer_will_close:1;
|
||||
|
|
|
@ -1078,6 +1078,14 @@ early_bail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
lws_vhost_set_mounts(struct lws_vhost *vh, const struct lws_http_mount *mounts)
|
||||
{
|
||||
#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)
|
||||
vh->http.mount_list = mounts;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
lws_init_vhost_client_ssl(const struct lws_context_creation_info *info,
|
||||
struct lws_vhost *vhost)
|
||||
|
|
|
@ -955,6 +955,9 @@ lws_find_mount(struct lws *wsi, const char *uri_ptr, int uri_len)
|
|||
lws_metrics_tag_wsi_add(wsi, "mnt", hm->mountpoint);
|
||||
#endif
|
||||
|
||||
if (hm->origin_protocol == LWSMPRO_NO_MOUNT)
|
||||
return NULL;
|
||||
|
||||
if (hm->origin_protocol == LWSMPRO_CALLBACK ||
|
||||
((hm->origin_protocol == LWSMPRO_CGI ||
|
||||
lws_hdr_total_length(wsi, WSI_TOKEN_GET_URI) ||
|
||||
|
@ -1782,6 +1785,7 @@ lws_http_action(struct lws *wsi)
|
|||
|
||||
/* can we serve it from the mount list? */
|
||||
|
||||
wsi->mount_hit = 0;
|
||||
hit = lws_find_mount(wsi, uri_ptr, uri_len);
|
||||
if (!hit) {
|
||||
/* deferred cleanup and reset to protocols[0] */
|
||||
|
@ -1800,6 +1804,8 @@ lws_http_action(struct lws *wsi)
|
|||
goto after;
|
||||
}
|
||||
|
||||
wsi->mount_hit = 1;
|
||||
|
||||
#if defined(LWS_WITH_FILE_OPS)
|
||||
s = uri_ptr + hit->mountpoint_len;
|
||||
#endif
|
||||
|
|
|
@ -1071,6 +1071,9 @@ malformed:
|
|||
if (!h)
|
||||
return -1;
|
||||
|
||||
if (h->wsi && h->wsi->mount_hit)
|
||||
break;
|
||||
|
||||
lwsl_info("%s: LWS_CALLBACK_HTTP\n", __func__);
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue