Commit c431904b authored by Бобби's avatar Бобби Committed by Cesanta Bot

Send extra options with OPTIONS

CL: Send extra options with OPTIONS. Integrate https://github.com/cesanta/mongoose/pull/657

PUBLISHED_FROM=6ee609a92febd8d908f7713f94fb73657443a09a
parent c2a10601
...@@ -8360,9 +8360,11 @@ void mg_http_send_digest_auth_request(struct mg_connection *c, ...@@ -8360,9 +8360,11 @@ void mg_http_send_digest_auth_request(struct mg_connection *c,
domain, (unsigned long) mg_time()); domain, (unsigned long) mg_time());
} }
static void mg_http_send_options(struct mg_connection *nc) { static void mg_http_send_options(struct mg_connection *nc,
struct mg_serve_http_opts *opts) {
mg_send_response_line(nc, 200, opts->extra_headers);
mg_printf(nc, "%s", mg_printf(nc, "%s",
"HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, OPTIONS" "Allow: GET, POST, HEAD, CONNECT, OPTIONS"
#if MG_ENABLE_HTTP_WEBDAV #if MG_ENABLE_HTTP_WEBDAV
", MKCOL, PUT, DELETE, PROPFIND, MOVE\r\nDAV: 1,2" ", MKCOL, PUT, DELETE, PROPFIND, MOVE\r\nDAV: 1,2"
#endif #endif
...@@ -8469,7 +8471,7 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path, ...@@ -8469,7 +8471,7 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
#endif #endif
#endif /* MG_ENABLE_HTTP_WEBDAV */ #endif /* MG_ENABLE_HTTP_WEBDAV */
} else if (!mg_vcmp(&hm->method, "OPTIONS")) { } else if (!mg_vcmp(&hm->method, "OPTIONS")) {
mg_http_send_options(nc); mg_http_send_options(nc, opts);
} else if (is_directory && index_file == NULL) { } else if (is_directory && index_file == NULL) {
#if MG_ENABLE_DIRECTORY_LISTING #if MG_ENABLE_DIRECTORY_LISTING
if (strcmp(opts->enable_directory_listing, "yes") == 0) { if (strcmp(opts->enable_directory_listing, "yes") == 0) {
......
...@@ -2556,9 +2556,11 @@ void mg_http_send_digest_auth_request(struct mg_connection *c, ...@@ -2556,9 +2556,11 @@ void mg_http_send_digest_auth_request(struct mg_connection *c,
domain, (unsigned long) mg_time()); domain, (unsigned long) mg_time());
} }
static void mg_http_send_options(struct mg_connection *nc) { static void mg_http_send_options(struct mg_connection *nc,
struct mg_serve_http_opts *opts) {
mg_send_response_line(nc, 200, opts->extra_headers);
mg_printf(nc, "%s", mg_printf(nc, "%s",
"HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, OPTIONS" "Allow: GET, POST, HEAD, CONNECT, OPTIONS"
#if MG_ENABLE_HTTP_WEBDAV #if MG_ENABLE_HTTP_WEBDAV
", MKCOL, PUT, DELETE, PROPFIND, MOVE\r\nDAV: 1,2" ", MKCOL, PUT, DELETE, PROPFIND, MOVE\r\nDAV: 1,2"
#endif #endif
...@@ -2665,7 +2667,7 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path, ...@@ -2665,7 +2667,7 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
#endif #endif
#endif /* MG_ENABLE_HTTP_WEBDAV */ #endif /* MG_ENABLE_HTTP_WEBDAV */
} else if (!mg_vcmp(&hm->method, "OPTIONS")) { } else if (!mg_vcmp(&hm->method, "OPTIONS")) {
mg_http_send_options(nc); mg_http_send_options(nc, opts);
} else if (is_directory && index_file == NULL) { } else if (is_directory && index_file == NULL) {
#if MG_ENABLE_DIRECTORY_LISTING #if MG_ENABLE_DIRECTORY_LISTING
if (strcmp(opts->enable_directory_listing, "yes") == 0) { if (strcmp(opts->enable_directory_listing, "yes") == 0) {
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
* license, as set out in <https://www.cesanta.com/license>. * license, as set out in <https://www.cesanta.com/license>.
*/ */
#include "mongoose.h"
#include "src/mg_internal.h"
#include "unit_test.h" #include "unit_test.h"
#include "common/cs_md5.h"
#include "common/test_main.h" #include "common/test_main.h"
#include "common/test_util.h" #include "common/test_util.h"
#include "common/cs_md5.h" #include "mongoose.h"
#include "src/mg_internal.h"
#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L && !defined(WIN32) #if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L && !defined(WIN32)
#define __func__ "" #define __func__ ""
...@@ -2011,7 +2011,8 @@ static const char *test_http(void) { ...@@ -2011,7 +2011,8 @@ static const char *test_http(void) {
char buf[50] = "", status[100] = "", mime1[20] = "", mime2[100] = ""; char buf[50] = "", status[100] = "", mime1[20] = "", mime2[100] = "";
char opt_buf[1024] = ""; char opt_buf[1024] = "";
const char *opt_answer = const char *opt_answer =
"HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, OPTIONS, MKCOL, " "HTTP/1.1 200 OK\r\nServer: Mongoose/" MG_VERSION
"\r\nAllow: GET, POST, HEAD, CONNECT, OPTIONS, MKCOL, "
"PUT, DELETE, PROPFIND, MOVE"; "PUT, DELETE, PROPFIND, MOVE";
char url[1000]; char url[1000];
......
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