Commit b12cc9fd authored by Sergey Lyubka's avatar Sergey Lyubka

Refactored handle_options_request() to use mg_write() with less copying

parent a61c3a26
...@@ -3824,14 +3824,13 @@ static void handle_ssi_file_request(struct mg_connection *conn, ...@@ -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) { ...@@ -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) &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment