Commit Graph

258 Commits

Author SHA1 Message Date
cpq
5bd22cb5e4 Add mg_http_next_multipart() 2021-03-17 07:43:29 +00:00
cpq
4528cc28ef Add sizep param to mg_file_read() 2021-03-15 09:16:34 +00:00
cpq
6366c832b0 Add struct mg_http_serve_opts::extra_headers 2021-03-10 07:56:14 +00:00
cpq
e84ea91a4a Process chunked body before sending MG_EV_HTTP_MSG 2021-03-09 08:21:29 +00:00
cpq
2dcb10ef36 Less verbose test 2021-03-08 15:45:09 +00:00
cpq
1b5cc341a5 Add streaming client support, MG_EV_HTTP_CHUNK 2021-03-08 15:41:16 +00:00
cpq
602c5c0866 Refactor mg_url_encode 2021-02-15 14:42:55 +00:00
cpq
d5a1d5a5e8 Stricter realpath checks 2021-02-11 15:03:22 +00:00
cpq
0a9303bb07 Stricter mg_http_parse() 2021-02-09 21:16:33 +00:00
cpq
6827972f71 Fix #1210 - on win32, open upload file in binary mode 2021-02-02 08:43:56 +00:00
cpq
d327ee9834 Improve SNI 2021-01-30 13:03:11 +00:00
cpq
5118355732 Use 64bit file ops even on 32bit systems 2021-01-26 17:43:31 +00:00
cpq
3c851bcfc3 mg_file_write -> mg_file_printf 2021-01-26 16:30:44 +00:00
cpq
9eabf3fa81 URL decoding URI 2021-01-21 17:14:08 +00:00
cpq
89beadd2ce Squash warning in unit test 2021-01-21 10:24:49 +00:00
cpq
6ecb6c1500 Fix DNS timeout, add unit test 2021-01-21 10:00:18 +00:00
cpq
ae6fd6aa35 Add extra headers param to mg_ws_upgrade() 2021-01-16 22:48:43 +00:00
cpq
c7e09bd7b4 Add SSI include file=, include virtual= 2021-01-02 17:57:51 +00:00
cpq
86824795a0 Pass opts structure to mg_http_serve_dir() 2021-01-02 12:30:09 +00:00
cpq
749326c83a Add more mg_http_parse unit tests 2020-12-24 14:33:23 +00:00
cpq
9657577c00 Fix typo in fuzz test 2020-12-24 09:09:25 +00:00
cpq
9f5216d259 Add more fuzz tests 2020-12-24 09:07:55 +00:00
cpq
e0a1feafe0 Fix localhost resolution 2020-12-23 10:15:09 +00:00
cpq
c3aae185df Add ipv6 server test 2020-12-22 10:16:31 +00:00
cpq
2e87783246 Add IPv6 client test 2020-12-22 09:44:59 +00:00
cpq
b93456f512 Do not create socket until resolved 2020-12-21 12:26:44 +00:00
cpq
1052ee0766 Fix openssl build, and add openssl test 2020-12-20 21:45:58 +00:00
cpq
29534218d7 IPv6 related refactoring 2020-12-20 16:55:33 +00:00
cpq
82a378e519 Add extra param to http_reply() 2020-12-17 22:47:55 +00:00
cpq
29d31ba919 More boundary checks for mg_dns_parse() 2020-12-17 19:14:17 +00:00
cpq
f176e1ae59 Handle more mime types 2020-12-15 11:58:30 +00:00
cpq
348c579521 Add dns test case 2020-12-14 09:31:23 +00:00
cpq
09beadb98a Fix c++ fuzzer build 2020-12-13 16:56:30 +00:00
cpq
5b265a76bd Add minor case to fuzzer 2020-12-13 16:33:46 +00:00
cpq
c5a4a1c6f2 Remove debug leftover 2020-12-13 00:37:04 +00:00
cpq
88ada54045 More tests 2020-12-12 20:38:09 +00:00
cpq
f3f397f31e Add MQTT client example 2020-12-12 10:03:19 +00:00
cpq
d806ed5d5f Better coverage 2020-12-11 22:58:50 +00:00
cpq
90686ee5c9 Add ws examples 2020-12-11 17:35:58 +00:00
cpq
85c5577955 mg_dns_parse_name() recursion protection 2020-12-11 14:02:52 +00:00
cpq
30d4a1ad0f Fix mg_sntp_parse() 2020-12-11 13:16:51 +00:00
cpq
1b551741b8 Fix mg_url_decode fuzz 2020-12-11 09:35:50 +00:00
cpq
cf62702f08 Switch to hivemq 2020-12-10 16:36:24 +00:00
cpq
d1b8f9e01f Fuzz-test mg_http_var and base64 2020-12-07 18:52:40 +00:00
cpq
7ea3293aba More tests 2020-12-07 08:54:58 +00:00
cpq
cb7743fa39 Move tests -> test 2020-12-06 23:19:56 +00:00
cpq
6691a2fdad Add badges 2020-12-05 11:46:12 +00:00
cpq
f2fba1d200 7.0 refactor 2020-12-05 11:26:32 +00:00
Deomid Ryabkov
be64f81eee Add mg_next_query_string_entry_n() and mg_url_decode_n()
Move to mg_util.h so encode and decode are next ot each other.

Pull out mg_next_list_entry_n() for advanced use cases.

Add unit tests.
2020-10-24 22:53:50 +01:00
Deomid Ryabkov
b0a1cd7b0d Sync src with amalgamated versions
Now src contains exactly what's embedded in mongoose.c and .h, nothing more.

Added `tools/amalgam.sh` to aamlgamate both files at once.

There are no functional changes to mongoose.c, .h in this PR, only slight filename changes.
2020-07-08 02:08:49 +01:00
Sergey Lyubka
f778d22eac Make it possible to override default FS update algorithm
PUBLISHED_FROM=774a111548da97bd9d195e177b5fb66b0fd66135
2020-06-11 18:27:48 +01:00
Sergey Lyubka
3aa76dcaec Subst CREDPARAMS
PUBLISHED_FROM=545e8dff4ea0bef061c893252c613e3429f56184
2020-06-11 18:27:46 +01:00
Deomid "rojer" Ryabkov
95fcb261eb Fix processing of keep-alive requests when chunks are consumed
PUBLISHED_FROM=136ce2ed4f143d7ee246e5fd1078c431e205bb3a
2020-05-22 23:07:38 +00:00
Sergey Lyubka
4ea452307e Update certs used for SSL test
PUBLISHED_FROM=2236ecf7fe06bdaf9a89e697b83ff69e1f8c805c
2020-05-21 16:17:12 +01:00
Deomid Ryabkov
10b11b03a8 Add mg_dns_encode_name_s for non-NUL terminated strings
PUBLISHED_FROM=012e2939021d1b275a39632fd2982891d2c98c4e
2019-12-29 19:33:41 +00:00
Sergey Lyubka
ff4649fe42 Better UI
PUBLISHED_FROM=50f0cafa84cd06428f0da376d85766dcf62af9da
2019-07-12 12:33:28 +00:00
Sergey Lyubka
1a38e91042 Next
PUBLISHED_FROM=6fa0be81ce429b8db9e3ed572cb4a876b6fb2693
2019-07-12 09:33:26 +00:00
Sergey Lyubka
2bdbfc27f6 Integrate https://github.com/cesanta/mongoose/issues/1008
PUBLISHED_FROM=1b7bf2d7318568851e6c8f07451cd3982d9498b6
2019-06-13 07:48:28 +00:00
Deomid Ryabkov
e5910da300 Deliver EV_CLOSE to the last endpoint handler
CL: mg: Deliver EV_CLOSE to the last endpoint handler

PUBLISHED_FROM=02ee2c6627ed9ee1d35022244f71dfe1877ce2c0
2019-03-19 13:15:41 +00:00
Sergey Lyubka
23533b83a4 Allow NULL handler for mg_bind and mg_connect
CL:  Allow NULL handler for mg_bind and mg_connect

PUBLISHED_FROM=4963d5c022c2c57dd03101d9c7e72ca910c3bb61
2019-03-06 12:33:24 +00:00
Deomid Ryabkov
1e9fabe1ca Fix handling of WS handshake error response
Check response code, make sure it's 101.
Pass http_message to the client to keep it appraised.
This represents a slight change in the API -
in case of an error MG_EV_WEBSOCKET_HANDSHAKE_DONE will now be delivered where previosuly connection would just hang.
Clients that do not examine the argument may for a moment think handshake has succeeded but in fact connection will be closed immediately.

CL: mg: Fix handling of WS handshake error response

PUBLISHED_FROM=645a43d9e5bee216e54411f85827c9b974e9a7d1
2019-02-14 21:19:34 +00:00
Deomid Ryabkov
c3057df3f5 Fix mongoose CI test
CL: none

PUBLISHED_FROM=9510e460251c250cb6a67a40edc0af515044f9fe
2019-02-08 17:38:56 +00:00
Deomid Ryabkov
86ffa3a3ea Properly support MQTT wildcards when matching topics
CL: mg: Properly support MQTT wildcards when matching topics

PUBLISHED_FROM=aa60a71d488f4b56dff0951886c8a9a4066fd4f2
2019-01-22 12:19:04 +00:00
Бобби
c431904b56 Send extra options with OPTIONS
CL: Send extra options with OPTIONS. Integrate https://github.com/cesanta/mongoose/pull/657

PUBLISHED_FROM=6ee609a92febd8d908f7713f94fb73657443a09a
2019-01-16 11:33:57 +00:00
Deomid Ryabkov
3130e59244 Stop reading if connection is closing
CL: none

PUBLISHED_FROM=3b74ca02e2960bbbf130f6d95aef679f2917e824
2018-11-02 18:12:34 +00:00
Deomid Ryabkov
05c687e251 Fix handling of keepalive HTTP requests/responses
Clean the HTTP connection state when ia request/response has been fully
buffered and handler invoked.

Fixes https://github.com/cesanta/mongoose/issues/971

CL: mg: Fix handling of keepalive HTTP requests/responses

PUBLISHED_FROM=70c854aa306aacb9161f6ee48841f38dc0312e6b
2018-09-27 12:51:18 +00:00
Deomid Ryabkov
1c8449cea6 Fix pipelining issue with multipart upload
Do not clear buffer at the end of multipart request to allow following request to proceed.

Closes https://github.com/cesanta/mongoose/pull/940

CL: mg: Fix pipelining issue with multipart upload

PUBLISHED_FROM=cc7d38b126eaa863553ee4e124cfafcd72030fcf
2018-06-26 12:05:04 +00:00
Deomid Ryabkov
339bbee0df mg_file_upload_handler: Support multiple files
curl -F file1 -F file2 ...

Add a unit test and fix a minor memory leak when returning an error.

CL: mg_file_upload_handler: Support multiple files

PUBLISHED_FROM=5c4bf2be676346fb782e80f50f79df6a6721ac88
2018-06-20 13:35:31 +00:00
Deomid Ryabkov
e89be2e944 Add mg_url_encode_opt()
CL: Add `mg_url_encode_opt()` - a parametrized version of `mg_url_encode()`

PUBLISHED_FROM=17fa57a7a5325b51b6e3aef3855eac4e82c35782
2018-04-10 11:04:31 +00:00
Deomid Ryabkov
c2fbff6d0e Fix mg_http_parse_header
Per standard, cookies are delimited by `; `.

CL: Fix mg_http_parse_header: treat ";" as a delimiter.

PUBLISHED_FROM=039243c30f5fabf4a4700a43506f841b3268306a
2018-04-10 10:19:36 +00:00
Deomid Ryabkov
3e33e57707 Mongoose net_if and ssl_if refactoring
A major cleanup, disentangling net_if and ssl_if.
Pulled a lot of common logic into the core and reduced size of net_if implementations.

CL: Mongoose net_if and ssl_if refactoring

PUBLISHED_FROM=29bd4dcb264a1fd96b3dd164e2d880e1c2c0921e
2018-03-30 23:19:49 +00:00
Serge A. Zaitsev
d16dbc197f mongoose: fix http pipeline
mongoose: fix formatting

mongoose: fix formatting

mongoose: remove debugging messages

PUBLISHED_FROM=1194e018001cc5f2b598096593d7aac4ec8dc04d
2018-03-20 16:41:56 +00:00
Serge A. Zaitsev
127f27e375 mongoose: unit test for http get pipeline
PUBLISHED_FROM=00e8634913232eb2e50a0d739f85e81706dbc400
2018-03-17 16:35:04 +00:00
Deomid Ryabkov
a3c4a48ef7 Make sure test assertions are evaluated once
E.g. if `ASSERT_EQ(myfunc(), 123)` fails, `myfunc()` would be invoked again to print the actual value.
This can cause confusion sometimes.
To avoid this, we cast arguments to double, which is wide enough for most cases and we provide a variant for 64 bit value types for when it's not.
We also perform a check and fail if argument to the check results in loss of precision.

CL: none

PUBLISHED_FROM=a14551289d92e8a5dead21d16471ebddebe938a8
2018-02-10 12:19:40 +00:00
Dmitry Frank
b9b20c6494 Implement mg_http_parse_header2()
Which is a replacement of (deprecated) `mg_http_parse_header`, but,
similarly to `asprintf`, allocates a new buffer if the client-provided
one is not large enough.

Also use it throughout mongoose code, and thus some header-related
limitations are removed; in particular,
https://github.com/cesanta/mongoose/issues/813 is fixed.

CL: Mongoose Web Server: Deprecate `mg_http_parse_header()` and implement `mg_http_parse_header2()` instead, which allocates a new buffer if the client-provided one is not large enough (similarly to `asprintf`).
CL: Mongoose Web Server: Fix limitations of header value lengths, e.g. when parsing authentication headers such as nonce, etc.

PUBLISHED_FROM=c75b1bbbbdb294ea85075ce69b1368f115fdd1ef
2018-02-07 23:04:29 +00:00
Deomid Ryabkov
50ecc30b4d Commonize unit test main()
CL: none

PUBLISHED_FROM=ee76407d89f3fcbe3da23810117a374d06af0a25
2018-02-07 16:19:32 +00:00
Dmitry Frank
7bf5144e62 Make tests work on public repo as well
PUBLISHED_FROM=78acb18d597b6f47f31da13087fa6685f21ce445
2018-02-05 14:35:37 +00:00
Dmitry Frank
aba60dadec Add mg_ prefix to mongoose sources
CL: none

PUBLISHED_FROM=d6ebe5fa88c61ae3b8569897d9b09d54610bec73
2018-02-03 01:20:47 +02:00
Dmitry Frank
f29457e967 Remove tunneling from mongoose
CL: Mongoose Web Server: Remove tunneling functionality which was used by nobody

PUBLISHED_FROM=38b9e8ae7b0a5a1dbba5cff4074843dc681267d3
2018-02-02 21:50:13 +00:00
Dmitry Frank
8742fac5d8 Publish mongoose src and tests
CL: Mongoose Web Server: Publish sources and tests

Resolves https://github.com/cesanta/mongoose/issues/745

PUBLISHED_FROM=7ecd7a3c518cfa614a6ba0838678dcb91b75a8c0
2018-02-02 15:49:55 +00:00
Marko Mikulicic
8927c9d22b Merge dev branch code named Fossa as next stable Mongoose 2015-09-08 14:34:30 +02:00
Sergey Lyubka
14d6f71f82 Fix unit test 2015-05-20 10:50:32 +01:00
Sergey Lyubka
bf7a115bf2 Fix url rewrites 2015-05-11 09:13:46 +01:00
Sergey Lyubka
2d1d2e6534 SIZE_MAX is not defined on MSVC6, use (size_t) ~0 2015-03-17 17:00:59 +00:00
Dinis Rosário
3bd79c7cd5 Fix remove_double_dots_and_double_slashes removing all the dots leading http server to serve wrong URI
If the uri is something like '/js/...jquery.js', remove_double_dots_and_double_slashes will remove the 3 dots and the http server will serves the /js/jquery.js file.
remove_double_dots_and_double_slashes should check if a dot or double dots is followed by a slash (or backslash) and only remove this to avoid disclosure attack.
2015-03-17 16:04:59 +01:00
Sergey Lyubka
c52e0744cb Squashed warnings after size_t change 2015-03-17 13:18:15 +00:00
Sergey Lyubka
e4ad3010be Fix #416 2014-12-30 03:56:29 +00:00
Sergey Lyubka
710b888122 Added -pthread to test/Makefile::CFLAGS 2014-10-17 20:12:29 +01:00
Sergey Lyubka
80db048578 Added more dependencies in test/Makefile 2014-09-15 01:28:03 +01:00
Sergey Lyubka
fac0e9b0ac Moved unit test to dedicated dir 2014-09-09 18:23:48 +01:00
Sergey Lyubka
5a3b1123f6 tests moved under build 2013-12-07 17:47:14 +00:00
Sergey Lyubka
af7efd980c Adjusting unit test for core 2013-12-06 22:14:55 +00:00
Sergey Lyubka
ebf9ee089b Do not send 500 when timing out getreq() 2013-12-05 11:12:07 +00:00
Sergey Lyubka
37751a2875 directory ops moved to directory.c 2013-11-23 10:24:25 +00:00
Sergey Lyubka
5153eebc9b mg_read() does not block on content_len=0. mg_read() reads until socket is closed if content-length is not provided 2013-10-01 17:47:32 +01:00
Sergey Lyubka
70154f6c23 Moved mod_lua.c to src/lua.c 2013-10-01 15:16:09 +01:00
Sergey Lyubka
ecbf79135f Refactored API, returned back to event-based handlers. Upload and Websocket API simplified 2013-09-28 11:00:54 +01:00
Sergey Lyubka
98214ce1a4 Removed init_lua() and open_file() callbacks 2013-09-26 09:35:07 +01:00
Sergey Lyubka
46e04e857c Added test for dir with non-ascii char 2013-09-24 10:08:39 +01:00
Sergey Lyubka
e556a487e0 Fix for the SCRIPT_NAME in the presence of PATH_INFO, https://code.google.com/p/mongoose/issues/detail?id=403 2013-09-07 18:49:24 +01:00