mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-13 17:00:19 +00:00
Setting content-length
This commit is contained in:
1 parent
e6357396ef
commit
ef4bd8f758
1 file changed
+11
-5
+11
-5
@@ -6,11 +6,17 @@ static void *callback(enum mg_event event,
|
|||||||
struct mg_connection *conn,
|
struct mg_connection *conn,
|
||||||
const struct mg_request_info *request_info) {
|
const struct mg_request_info *request_info) {
|
||||||
if (event == MG_NEW_REQUEST) {
|
if (event == MG_NEW_REQUEST) {
|
||||||
// Echo requested URI back to the client
|
const char *content = "hello from mongoose!";
|
||||||
mg_printf(conn, "HTTP/1.1 200 OK\r\n"
|
mg_printf(conn,
|
||||||
"Content-Type: text/plain\r\n\r\n"
|
"HTTP/1.1 200 OK\r\n"
|
||||||
"%s", request_info->uri);
|
"Content-Type: text/plain\r\n"
|
||||||
return ""; // Mark as processed
|
"Content-Length: %d\r\n" // Always set Content-Length
|
||||||
|
"\r\n"
|
||||||
|
"%s",
|
||||||
|
strlen(content),
|
||||||
|
content);
|
||||||
|
// Mark as processed
|
||||||
|
return "";
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user