mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-14 01:38:01 +08:00
Add Content-Type header to the SSI files
This commit is contained in:
parent
3982e065c8
commit
655f9a9f79
@ -3278,8 +3278,9 @@ static char *mg_ssi(const char *path, const char *root, int depth) {
|
||||
|
||||
void mg_http_serve_ssi(struct mg_connection *c, const char *root,
|
||||
const char *fullpath) {
|
||||
const char *headers = "Content-Type: text/html; charset=utf-8\r\n";
|
||||
char *data = mg_ssi(fullpath, root, 0);
|
||||
mg_http_reply(c, 200, "", "%s", data == NULL ? "" : data);
|
||||
mg_http_reply(c, 200, headers, "%s", data == NULL ? "" : data);
|
||||
free(data);
|
||||
}
|
||||
#endif
|
||||
|
@ -14,6 +14,7 @@
|
||||
//
|
||||
// Alternatively, you can license this software under a commercial
|
||||
// license, as set out in <https://www.cesanta.com/license>.
|
||||
|
||||
#ifndef MONGOOSE_H
|
||||
#define MONGOOSE_H
|
||||
|
||||
|
@ -78,8 +78,9 @@ static char *mg_ssi(const char *path, const char *root, int depth) {
|
||||
|
||||
void mg_http_serve_ssi(struct mg_connection *c, const char *root,
|
||||
const char *fullpath) {
|
||||
const char *headers = "Content-Type: text/html; charset=utf-8\r\n";
|
||||
char *data = mg_ssi(fullpath, root, 0);
|
||||
mg_http_reply(c, 200, "", "%s", data == NULL ? "" : data);
|
||||
mg_http_reply(c, 200, headers, "%s", data == NULL ? "" : data);
|
||||
free(data);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
#ifndef MONGOOSE_H
|
||||
#define MONGOOSE_H
|
||||
|
||||
|
@ -507,6 +507,14 @@ static void test_http_server(void) {
|
||||
"recurse\n\n"
|
||||
"recurse\n\n"
|
||||
"recurse\n\n") == 0);
|
||||
{
|
||||
struct mg_http_message hm;
|
||||
mg_http_parse(buf, strlen(buf), &hm);
|
||||
ASSERT(mg_http_get_header(&hm, "Content-Length") != NULL);
|
||||
ASSERT(mg_http_get_header(&hm, "Content-Type") != NULL);
|
||||
ASSERT(mg_strcmp(*mg_http_get_header(&hm, "Content-Type"),
|
||||
mg_str("text/html; charset=utf-8")) == 0);
|
||||
}
|
||||
|
||||
ASSERT(fetch(&mgr, buf, url, "GET /badroot HTTP/1.0\r\n\n") == 400);
|
||||
#if MG_ARCH == MG_ARCH_WIN32
|
||||
|
Loading…
x
Reference in New Issue
Block a user