Commit Graph

96 Commits

Author SHA1 Message Date
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
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
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
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
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
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
b461edabd9 Squashed warnings 2013-09-07 18:46:50 +01:00
Sergey Lyubka
d8596fae27 Fixed unit test 2013-08-19 19:10:17 +01:00
Sergey Lyubka
2055d41a9f Corrected misplaced brackets in parse_http_message() 2013-08-14 10:55:36 +01:00
Sergey Lyubka
743f48b8e0 Added mg_exec_lua_script, mg_prepare_lua_environment -> prepare_lua_environment 2013-08-08 13:11:05 +01:00
Sergey Lyubka
e53d05637a Binding to IPv6 addresses 2013-07-28 12:15:16 +01:00
Sergey Lyubka
62d66201c9 make match_prefix() case-insensitive 2013-07-25 07:07:25 +01:00
Sergey Lyubka
c80a88a407 Added test for uploading 2 files 2013-07-23 08:17:00 +01:00