mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
Send extra options with OPTIONS
CL: Send extra options with OPTIONS. Integrate https://github.com/cesanta/mongoose/pull/657 PUBLISHED_FROM=6ee609a92febd8d908f7713f94fb73657443a09a
This commit is contained in:
1 parent
c2a10601b9
commit
c431904b56
3 files changed
+21
-16
No files matched your search
+8
-6
@@ -6563,9 +6563,9 @@ void mg_http_handler(struct mg_connection *nc, int ev,
|
||||
if (io->len > 0 &&
|
||||
(req_len = mg_parse_http(io->buf, io->len, hm, is_req)) > 0) {
|
||||
/*
|
||||
* For HTTP messages without Content-Length, always send HTTP message
|
||||
* before MG_EV_CLOSE message.
|
||||
*/
|
||||
* For HTTP messages without Content-Length, always send HTTP message
|
||||
* before MG_EV_CLOSE message.
|
||||
*/
|
||||
int ev2 = is_req ? MG_EV_HTTP_REQUEST : MG_EV_HTTP_REPLY;
|
||||
hm->message.len = io->len;
|
||||
hm->body.len = io->buf + io->len - hm->body.p;
|
||||
@@ -8360,9 +8360,11 @@ void mg_http_send_digest_auth_request(struct mg_connection *c,
|
||||
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",
|
||||
"HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, OPTIONS"
|
||||
"Allow: GET, POST, HEAD, CONNECT, OPTIONS"
|
||||
#if MG_ENABLE_HTTP_WEBDAV
|
||||
", MKCOL, PUT, DELETE, PROPFIND, MOVE\r\nDAV: 1,2"
|
||||
#endif
|
||||
@@ -8469,7 +8471,7 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
|
||||
#endif
|
||||
#endif /* MG_ENABLE_HTTP_WEBDAV */
|
||||
} 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) {
|
||||
#if MG_ENABLE_DIRECTORY_LISTING
|
||||
if (strcmp(opts->enable_directory_listing, "yes") == 0) {
|
||||
|
||||
+8
-6
@@ -759,9 +759,9 @@ void mg_http_handler(struct mg_connection *nc, int ev,
|
||||
if (io->len > 0 &&
|
||||
(req_len = mg_parse_http(io->buf, io->len, hm, is_req)) > 0) {
|
||||
/*
|
||||
* For HTTP messages without Content-Length, always send HTTP message
|
||||
* before MG_EV_CLOSE message.
|
||||
*/
|
||||
* For HTTP messages without Content-Length, always send HTTP message
|
||||
* before MG_EV_CLOSE message.
|
||||
*/
|
||||
int ev2 = is_req ? MG_EV_HTTP_REQUEST : MG_EV_HTTP_REPLY;
|
||||
hm->message.len = io->len;
|
||||
hm->body.len = io->buf + io->len - hm->body.p;
|
||||
@@ -2556,9 +2556,11 @@ void mg_http_send_digest_auth_request(struct mg_connection *c,
|
||||
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",
|
||||
"HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, OPTIONS"
|
||||
"Allow: GET, POST, HEAD, CONNECT, OPTIONS"
|
||||
#if MG_ENABLE_HTTP_WEBDAV
|
||||
", MKCOL, PUT, DELETE, PROPFIND, MOVE\r\nDAV: 1,2"
|
||||
#endif
|
||||
@@ -2665,7 +2667,7 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
|
||||
#endif
|
||||
#endif /* MG_ENABLE_HTTP_WEBDAV */
|
||||
} 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) {
|
||||
#if MG_ENABLE_DIRECTORY_LISTING
|
||||
if (strcmp(opts->enable_directory_listing, "yes") == 0) {
|
||||
|
||||
+5
-4
@@ -15,12 +15,12 @@
|
||||
* license, as set out in <https://www.cesanta.com/license>.
|
||||
*/
|
||||
|
||||
#include "mongoose.h"
|
||||
#include "src/mg_internal.h"
|
||||
#include "unit_test.h"
|
||||
#include "common/cs_md5.h"
|
||||
#include "common/test_main.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)
|
||||
#define __func__ ""
|
||||
@@ -2011,7 +2011,8 @@ static const char *test_http(void) {
|
||||
char buf[50] = "", status[100] = "", mime1[20] = "", mime2[100] = "";
|
||||
char opt_buf[1024] = "";
|
||||
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";
|
||||
char url[1000];
|
||||
|
||||
|
||||
Reference in new issue
Block a user