Browse Source

[core] merge uri_raw and uri_clean hooks

hooks are run consecutively in http_response_prepare()

merge uri_raw before uri_clean to preserve existing ordering
master
Glenn Strauss 6 months ago
parent
commit
0afab29cfb
  1. 20
      src/plugin.c
  2. 1
      src/plugin.h
  3. 11
      src/response.c

20
src/plugin.c

@ -29,7 +29,6 @@ array plugin_stats; /* global */
typedef enum {
PLUGIN_FUNC_HANDLE_URI_CLEAN,
PLUGIN_FUNC_HANDLE_URI_RAW,
PLUGIN_FUNC_HANDLE_REQUEST_ENV,
PLUGIN_FUNC_HANDLE_REQUEST_DONE,
PLUGIN_FUNC_HANDLE_CONNECTION_ACCEPT,
@ -322,7 +321,6 @@ static void plugins_call_fn_srv_data_all(server * const srv, const int e) {
}
PLUGIN_CALL_FN_REQ_DATA(PLUGIN_FUNC_HANDLE_URI_CLEAN, handle_uri_clean)
PLUGIN_CALL_FN_REQ_DATA(PLUGIN_FUNC_HANDLE_URI_RAW, handle_uri_raw)
PLUGIN_CALL_FN_REQ_DATA(PLUGIN_FUNC_HANDLE_REQUEST_ENV, handle_request_env)
PLUGIN_CALL_FN_REQ_DATA(PLUGIN_FUNC_HANDLE_REQUEST_DONE, handle_request_done)
PLUGIN_CALL_FN_REQ_DATA(PLUGIN_FUNC_HANDLE_SUBREQUEST_START, handle_subrequest_start)
@ -452,8 +450,8 @@ handler_t plugins_call_init(server *srv) {
if (p->handle_uri_clean)
++offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN];
if (p->handle_uri_raw)
++offsets[PLUGIN_FUNC_HANDLE_URI_RAW];
if (p->handle_uri_raw && !p->handle_uri_clean)
++offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN]; /*(same as above)*/
if (p->handle_request_env)
++offsets[PLUGIN_FUNC_HANDLE_REQUEST_ENV];
if (p->handle_request_done)
@ -502,13 +500,19 @@ handler_t plugins_call_init(server *srv) {
force_assert(NULL != srv->plugin_slots);
memcpy(srv->plugin_slots, offsets, sizeof(offsets));
/* add handle_uri_raw before handle_uri_clean, but in same slot */
for (uint32_t i = 0; i < srv->plugins.used; ++i) {
plugin * const p = ps[i];
plugins_call_init_slot(srv, p->handle_uri_clean, p->data,
offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN]);
plugins_call_init_slot(srv, p->handle_uri_raw, p->data,
offsets[PLUGIN_FUNC_HANDLE_URI_RAW]);
offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN]);
}
for (uint32_t i = 0; i < srv->plugins.used; ++i) {
plugin * const p = ps[i];
if (!p->handle_uri_raw)
plugins_call_init_slot(srv, p->handle_uri_clean, p->data,
offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN]);
plugins_call_init_slot(srv, p->handle_request_env, p->data,
offsets[PLUGIN_FUNC_HANDLE_REQUEST_ENV]);
plugins_call_init_slot(srv, p->handle_request_done, p->data,

1
src/plugin.h

@ -98,7 +98,6 @@ int plugins_load(server *srv);
__attribute_cold__
void plugins_free(server *srv);
handler_t plugins_call_handle_uri_raw(request_st *r);
handler_t plugins_call_handle_uri_clean(request_st *r);
handler_t plugins_call_handle_subrequest_start(request_st *r);
handler_t plugins_call_handle_response_start(request_st *r);

11
src/response.c

@ -412,17 +412,6 @@ http_response_prepare (request_st * const r)
}
/**
*
* call plugins
*
* - based on the raw URL
*
*/
rc = plugins_call_handle_uri_raw(r);
if (HANDLER_GO_ON != rc) continue;
/**
*
* call plugins

Loading…
Cancel
Save