mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-20 19:41:58 +00:00
Refactored handle_options_request() to use mg_write() with less copying
This commit is contained in:
1 parent
a61c3a2636
commit
b12cc9fd49
1 file changed
+7
-8
+7
-8
@@ -3824,14 +3824,13 @@ static void handle_ssi_file_request(struct mg_connection *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_options(struct mg_connection *conn) {
|
static void handle_options_request(struct mg_connection *conn) {
|
||||||
conn->status_code = 200;
|
static const char reply[] = "HTTP/1.1 200 OK\r\n"
|
||||||
|
"Allow: GET, POST, HEAD, CONNECT, PUT, DELETE, OPTIONS, PROPFIND, MKCOL\r\n"
|
||||||
|
"DAV: 1\r\n\r\n";
|
||||||
|
|
||||||
mg_printf(conn, "%s", "HTTP/1.1 200 OK\r\n"
|
conn->status_code = 200;
|
||||||
"Content-Length: 0\r\n"
|
mg_write(conn, reply, sizeof(reply) - 1);
|
||||||
"Allow: GET, POST, HEAD, CONNECT, PUT, DELETE, "
|
|
||||||
"OPTIONS, PROPFIND, MKCOL\r\n"
|
|
||||||
"DAV: 1\r\n\r\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writes PROPFIND properties for a collection element
|
// Writes PROPFIND properties for a collection element
|
||||||
@@ -4502,7 +4501,7 @@ static void handle_request(struct mg_connection *conn) {
|
|||||||
handle_websocket_request(conn);
|
handle_websocket_request(conn);
|
||||||
#endif
|
#endif
|
||||||
} else if (!strcmp(ri->request_method, "OPTIONS")) {
|
} else if (!strcmp(ri->request_method, "OPTIONS")) {
|
||||||
send_options(conn);
|
handle_options_request(conn);
|
||||||
} else if (conn->ctx->config[DOCUMENT_ROOT] == NULL) {
|
} else if (conn->ctx->config[DOCUMENT_ROOT] == NULL) {
|
||||||
send_http_error(conn, 404, "Not Found", "Not Found");
|
send_http_error(conn, 404, "Not Found", "Not Found");
|
||||||
} else if (is_put_or_delete_request(conn) &&
|
} else if (is_put_or_delete_request(conn) &&
|
||||||
|
|||||||
Reference in new issue
Block a user