diff --git a/docs/c-api/http.h/intro.md b/docs/c-api/http.h/intro.md index f070b4b5..df5df05f 100644 --- a/docs/c-api/http.h/intro.md +++ b/docs/c-api/http.h/intro.md @@ -15,6 +15,7 @@ items: - { name: struct_http_message.md } - { name: struct_websocket_message.md } - { name: struct_mg_http_multipart_part.md } + - { name: struct_mg_ssi_call_ctx.md } --- diff --git a/docs/c-api/http.h/struct_mg_ssi_call_ctx.md b/docs/c-api/http.h/struct_mg_ssi_call_ctx.md new file mode 100644 index 00000000..2b430fd1 --- /dev/null +++ b/docs/c-api/http.h/struct_mg_ssi_call_ctx.md @@ -0,0 +1,14 @@ +--- +title: "struct mg_ssi_call_ctx" +decl_name: "struct mg_ssi_call_ctx" +symbol_kind: "struct" +signature: | + struct mg_ssi_call_ctx { + struct http_message *req; /* The request being processed. */ + struct mg_str file; /* Filesystem path of the file being processed. */ + struct mg_str arg; /* The argument passed to the tag: . */ + }; +--- + +SSI call context + diff --git a/mongoose.c b/mongoose.c index 111930bf..24ba9916 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5385,8 +5385,9 @@ static void mg_http_send_error(struct mg_connection *nc, int code, nc->flags |= MG_F_SEND_AND_CLOSE; } #ifndef MG_DISABLE_SSI -static void mg_send_ssi_file(struct mg_connection *, const char *, FILE *, int, - const struct mg_serve_http_opts *); +static void mg_send_ssi_file(struct mg_connection *nc, struct http_message *hm, + const char *path, FILE *fp, int include_level, + const struct mg_serve_http_opts *opts); static void mg_send_file_data(struct mg_connection *nc, FILE *fp) { char buf[BUFSIZ]; @@ -5396,8 +5397,8 @@ static void mg_send_file_data(struct mg_connection *nc, FILE *fp) { } } -static void mg_do_ssi_include(struct mg_connection *nc, const char *ssi, - char *tag, int include_level, +static void mg_do_ssi_include(struct mg_connection *nc, struct http_message *hm, + const char *ssi, char *tag, int include_level, const struct mg_serve_http_opts *opts) { char file_name[BUFSIZ], path[MAX_PATH_SIZE], *p; FILE *fp; @@ -5434,7 +5435,7 @@ static void mg_do_ssi_include(struct mg_connection *nc, const char *ssi, mg_set_close_on_exec(fileno(fp)); if (mg_match_prefix(opts->ssi_pattern, strlen(opts->ssi_pattern), path) > 0) { - mg_send_ssi_file(nc, path, fp, include_level + 1, opts); + mg_send_ssi_file(nc, hm, path, fp, include_level + 1, opts); } else { mg_send_file_data(nc, fp); } @@ -5458,16 +5459,12 @@ static void do_ssi_exec(struct mg_connection *nc, char *tag) { } #endif /* !MG_DISABLE_POPEN */ -static void mg_do_ssi_call(struct mg_connection *nc, char *tag) { - mg_call(nc, NULL, MG_EV_SSI_CALL, tag); -} - /* * SSI directive has the following format: * */ -static void mg_send_ssi_file(struct mg_connection *nc, const char *path, - FILE *fp, int include_level, +static void mg_send_ssi_file(struct mg_connection *nc, struct http_message *hm, + const char *path, FILE *fp, int include_level, const struct mg_serve_http_opts *opts) { static const struct mg_str btag = MG_MK_STR(". */ +}; + /* HTTP and websocket events. void *ev_data is described in a comment. */ #define MG_EV_HTTP_REQUEST 100 /* struct http_message * */ #define MG_EV_HTTP_REPLY 101 /* struct http_message * */ #define MG_EV_HTTP_CHUNK 102 /* struct http_message * */ #define MG_EV_SSI_CALL 105 /* char * */ +#define MG_EV_SSI_CALL_CTX 106 /* struct mg_ssi_call_ctx * */ #ifndef MG_DISABLE_HTTP_WEBSOCKET #define MG_EV_WEBSOCKET_HANDSHAKE_REQUEST 111 /* NULL */