httpd: upgrade to latest mongoose 5.5
This commit is contained in:
parent
0376ab3f28
commit
d46aa5114f
4 changed files with 1559 additions and 1112 deletions
4
3rdparty/mongoose/LICENSE
vendored
4
3rdparty/mongoose/LICENSE
vendored
|
@ -5,7 +5,7 @@ All rights reserved
|
|||
This code is dual-licensed: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2 as
|
||||
published by the Free Software Foundation. For the terms of this
|
||||
license, see http://www.gnu.org/licenses.
|
||||
license, see <http://www.gnu.org/licenses>.
|
||||
|
||||
You are free to use this code under the terms of the GNU General
|
||||
Public License, but WITHOUT ANY WARRANTY; without even the implied
|
||||
|
@ -13,4 +13,4 @@ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|||
See the GNU General Public License for more details.
|
||||
|
||||
Alternatively, you can license this code under a commercial
|
||||
license, as set out in http://cesanta.com/products.html.
|
||||
license, as set out in <http://cesanta.com/>.
|
||||
|
|
2383
3rdparty/mongoose/mongoose.c
vendored
2383
3rdparty/mongoose/mongoose.c
vendored
File diff suppressed because it is too large
Load diff
76
3rdparty/mongoose/mongoose.h
vendored
76
3rdparty/mongoose/mongoose.h
vendored
|
@ -15,12 +15,12 @@
|
|||
// Alternatively, you can license this library under a commercial
|
||||
// license, as set out in <http://cesanta.com/>.
|
||||
//
|
||||
// NOTE: Detailed API documentation is at http://cesanta.com/#docs
|
||||
// $Date: 2014-09-09 17:07:55 UTC $
|
||||
|
||||
#ifndef MONGOOSE_HEADER_INCLUDED
|
||||
#define MONGOOSE_HEADER_INCLUDED
|
||||
|
||||
#define MONGOOSE_VERSION "5.3"
|
||||
#define MONGOOSE_VERSION "5.5"
|
||||
|
||||
#include <stdio.h> // required for FILE
|
||||
#include <stddef.h> // required for size_t
|
||||
|
@ -37,7 +37,7 @@ struct mg_connection {
|
|||
const char *query_string; // URL part after '?', not including '?', or NULL
|
||||
|
||||
char remote_ip[48]; // Max IPv6 string length is 45 characters
|
||||
const char *local_ip; // Local IP address
|
||||
char local_ip[48]; // Local IP address
|
||||
unsigned short remote_port; // Client's port
|
||||
unsigned short local_port; // Local port number
|
||||
|
||||
|
@ -48,13 +48,14 @@ struct mg_connection {
|
|||
} http_headers[30];
|
||||
|
||||
char *content; // POST (or websocket message) data, or NULL
|
||||
size_t content_len; // content length
|
||||
size_t content_len; // Data length
|
||||
|
||||
int is_websocket; // Connection is a websocket connection
|
||||
int status_code; // HTTP status code for HTTP error handler
|
||||
int wsbits; // First byte of the websocket frame
|
||||
void *server_param; // Parameter passed to mg_add_uri_handler()
|
||||
void *connection_param; // Placeholder for connection-specific data
|
||||
void *callback_param;
|
||||
};
|
||||
|
||||
struct mg_server; // Opaque structure describing server instance
|
||||
|
@ -65,12 +66,26 @@ enum mg_event {
|
|||
MG_AUTH, // If callback returns MG_FALSE, authentication fails
|
||||
MG_REQUEST, // If callback returns MG_FALSE, Mongoose continues with req
|
||||
MG_REPLY, // If callback returns MG_FALSE, Mongoose closes connection
|
||||
MG_CLOSE, // Connection is closed
|
||||
MG_LUA, // Called before LSP page invoked
|
||||
MG_RECV, // Mongoose has received POST data chunk.
|
||||
// Callback should return a number of bytes to discard from
|
||||
// the receive buffer, or -1 to close the connection.
|
||||
MG_CLOSE, // Connection is closed, callback return value is ignored
|
||||
MG_WS_HANDSHAKE, // New websocket connection, handshake request
|
||||
MG_WS_CONNECT, // New websocket connection established
|
||||
MG_HTTP_ERROR // If callback returns MG_FALSE, Mongoose continues with err
|
||||
};
|
||||
typedef int (*mg_handler_t)(struct mg_connection *, enum mg_event);
|
||||
|
||||
// Websocket opcodes, from http://tools.ietf.org/html/rfc6455
|
||||
enum {
|
||||
WEBSOCKET_OPCODE_CONTINUATION = 0x0,
|
||||
WEBSOCKET_OPCODE_TEXT = 0x1,
|
||||
WEBSOCKET_OPCODE_BINARY = 0x2,
|
||||
WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8,
|
||||
WEBSOCKET_OPCODE_PING = 0x9,
|
||||
WEBSOCKET_OPCODE_PONG = 0xa
|
||||
};
|
||||
|
||||
// Server management functions
|
||||
struct mg_server *mg_create_server(void *server_param, mg_handler_t handler);
|
||||
void mg_destroy_server(struct mg_server **);
|
||||
|
@ -78,24 +93,27 @@ const char *mg_set_option(struct mg_server *, const char *opt, const char *val);
|
|||
int mg_poll_server(struct mg_server *, int milliseconds);
|
||||
const char **mg_get_valid_option_names(void);
|
||||
const char *mg_get_option(const struct mg_server *server, const char *name);
|
||||
void mg_set_listening_socket(struct mg_server *, int sock);
|
||||
int mg_get_listening_socket(struct mg_server *);
|
||||
void mg_iterate_over_connections(struct mg_server *, mg_handler_t);
|
||||
void mg_copy_listeners(struct mg_server *from, struct mg_server *to);
|
||||
struct mg_connection *mg_next(struct mg_server *, struct mg_connection *);
|
||||
void mg_wakeup_server(struct mg_server *);
|
||||
struct mg_connection *mg_connect(struct mg_server *, const char *, int, int);
|
||||
void mg_wakeup_server_ex(struct mg_server *, mg_handler_t, const char *, ...);
|
||||
struct mg_connection *mg_connect(struct mg_server *, const char *);
|
||||
|
||||
// Connection management functions
|
||||
void mg_send_status(struct mg_connection *, int status_code);
|
||||
void mg_send_header(struct mg_connection *, const char *name, const char *val);
|
||||
void mg_send_data(struct mg_connection *, const void *data, int data_len);
|
||||
void mg_printf_data(struct mg_connection *, const char *format, ...);
|
||||
size_t mg_send_data(struct mg_connection *, const void *data, int data_len);
|
||||
size_t mg_printf_data(struct mg_connection *, const char *format, ...);
|
||||
size_t mg_write(struct mg_connection *, const void *buf, int len);
|
||||
size_t mg_printf(struct mg_connection *conn, const char *fmt, ...);
|
||||
|
||||
int mg_websocket_write(struct mg_connection *, int opcode,
|
||||
const char *data, size_t data_len);
|
||||
size_t mg_websocket_write(struct mg_connection *, int opcode,
|
||||
const char *data, size_t data_len);
|
||||
size_t mg_websocket_printf(struct mg_connection* conn, int opcode,
|
||||
const char *fmt, ...);
|
||||
|
||||
// Deprecated in favor of mg_send_* interface
|
||||
int mg_write(struct mg_connection *, const void *buf, int len);
|
||||
int mg_printf(struct mg_connection *conn, const char *fmt, ...);
|
||||
void mg_send_file(struct mg_connection *, const char *path, const char *);
|
||||
void mg_send_file_data(struct mg_connection *, int fd);
|
||||
|
||||
const char *mg_get_header(const struct mg_connection *, const char *name);
|
||||
const char *mg_get_mime_type(const char *name, const char *default_mime_type);
|
||||
|
@ -107,20 +125,26 @@ int mg_parse_multipart(const char *buf, int buf_len,
|
|||
char *file_name, int file_name_len,
|
||||
const char **data, int *data_len);
|
||||
|
||||
|
||||
// Utility functions
|
||||
void *mg_start_thread(void *(*func)(void *), void *param);
|
||||
char *mg_md5(char buf[33], ...);
|
||||
int mg_authorize_digest(struct mg_connection *c, FILE *fp);
|
||||
int mg_url_encode(const char *src, size_t s_len, char *dst, size_t dst_len);
|
||||
int mg_url_decode(const char *src, int src_len, char *dst, int dst_len, int);
|
||||
int mg_terminate_ssl(struct mg_connection *c, const char *cert);
|
||||
int mg_forward(struct mg_connection *c, const char *addr);
|
||||
void *mg_mmap(FILE *fp, size_t size);
|
||||
void mg_munmap(void *p, size_t size);
|
||||
|
||||
// Lua utility functions
|
||||
#ifdef MONGOOSE_USE_LUA
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
void reg_string(lua_State *L, const char *name, const char *val);
|
||||
void reg_int(lua_State *L, const char *name, int val);
|
||||
void reg_function(lua_State *L, const char *,
|
||||
lua_CFunction, struct mg_connection *);
|
||||
#endif
|
||||
|
||||
// Templates support
|
||||
struct mg_expansion {
|
||||
const char *keyword;
|
||||
void (*handler)(struct mg_connection *);
|
||||
};
|
||||
void mg_template(struct mg_connection *, const char *text,
|
||||
struct mg_expansion *expansions);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -596,8 +596,6 @@ int MongooseHttpd::staticRequestHandler(struct mg_connection * connection, mg_ev
|
|||
case MG_HTTP_ERROR: // If callback returns MG_FALSE, Mongoose continues with err
|
||||
return MG_FALSE; // we don't handle errors - let mongoose do the work
|
||||
|
||||
// LUA not implemented - and will go away anyway
|
||||
case MG_LUA: // Called before LSP page invoked
|
||||
// client services not used/implemented. Signal 'close connection' to be sure
|
||||
case MG_CONNECT: // If callback returns MG_FALSE, connect fails
|
||||
case MG_REPLY: // If callback returns MG_FALSE, Mongoose closes connection
|
||||
|
|
Loading…
Add table
Reference in a new issue