Commit Graph

614 Commits

Author SHA1 Message Date
Farook Al-Sammarraie
b6a04058a1
Merge branch 'master' into gcc48 2022-04-25 09:34:52 +03:00
Dan Keenan
869a0abb04 Fix header name. 2022-04-21 19:51:22 -04:00
Dan Keenan
885ac41d99 Formatting fixes. 2022-04-20 16:26:09 -04:00
Dan Keenan
89226687ea Avoid exception handling. 2022-04-20 16:18:50 -04:00
Dan Keenan
33df7fc35b Handle extensions without mime types assigned to them. 2022-04-16 17:35:44 -04:00
Farook Al-Sammarraie
60b1d82999
Merge branch 'master' into gcc48 2022-04-16 16:07:05 +03:00
The-EDev
0f3721f5eb
removed mentions of is_callable in middleware.h 2022-04-16 16:05:41 +03:00
The-EDev
9f7ed83c45
Removed is_callable in favor of CallHelper + formatting 2022-04-16 16:04:49 +03:00
Vladislav Oleshko
74d94888d1 Generic app constructor 2022-04-13 20:49:22 +03:00
Vladislav Oleshko
d86b2d36f1 Add test, small fixes 2022-04-13 12:16:06 +03:00
Vladislav Oleshko
d9ba5787f1 Fix blueprint bug 2022-04-12 12:19:16 +03:00
Vladislav
cca8578556
Merge branch 'master' into blueprint-middleware 2022-04-12 10:52:45 +03:00
Dao-hui Chen
c2b8a60eb3 Concatenate log into one string and sending to std::cerr instead of multiple << operator 2022-04-12 09:18:38 +08:00
Vladislav Oleshko
eb2c0a58b2 Optimize dynamic call criteria, small fixes 2022-04-11 23:03:11 +03:00
Vladislav Oleshko
3b9e522523 Blueprint middleware prototype 2022-04-11 16:01:27 +03:00
The-EDev
facae48aa1
Allowed compiling on GCC 4.8 by using CallHelper instead of is_callable
Also fixed issue with ssl test string comparison (which caused random incorrect failures)
2022-04-11 06:24:43 +03:00
The-EDev
6a5c18a54f
Fixed issue where Crow wouldn't compile when using CROW_MIDDLEWARES with a pass-by-reference app 2022-04-09 04:45:32 +03:00
Farook Al-Sammarraie
57bf896ffd
Merge branch 'master' into cors-middleware-fix 2022-04-08 14:30:26 +03:00
Vladislav Oleshko
bccc03c141 Add inline decl to CORSRules helpers 2022-04-08 14:00:17 +03:00
The-EDev
0a739b35c6
fixed issue where SSL websockets wouldn't run due to HTTP upgrade 2022-04-07 15:54:50 +03:00
Farook Al-Sammarraie
6ffaf23375
Merge branch 'master' into crow-features 2022-04-04 21:44:11 +03:00
Luca Schlecker
44f51f4750 Crow's current features (ssl and compression) can now be enabled through 'CROW_FEATURES' instead of their own CMake variables.
The default features are the ones Crow was installed with but can be overridden by setting 'CROW_FEATURES' before the 'find_package' call.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2022-04-04 20:36:57 +02:00
Farook Al-Sammarraie
912330322b
Merge branch 'master' into master 2022-04-04 21:19:18 +03:00
Darrell Wright
dcbb8a15fd
Update common.h
Fixed extra {
2022-04-04 13:04:26 -04:00
Harald Siegmund
d6d5e45399 make multipart robust against ill-formed body, prevents SIGSEGV 2022-04-04 17:55:19 +02:00
Harald Siegmund
7c285db88c make multipart robust against ill-formed body, prevents SIGSEGV 2022-04-04 17:27:53 +02:00
Darrell Wright
338b59f329
Split up operator""_method
When wrapping calls to crow from other code bases, I have had to call `operator""_method` explicitly.  Breaking it into two methods, `method_from_string` and `operator""_method` allows one to compose this code elsewhere.
2022-04-03 13:32:45 -04:00
The-EDev
5f18548369
Fixed problem where GCC < 6 wouldn't compile Crow 2022-03-30 15:50:11 +03:00
The-EDev
a3c1af4b29
updated documentation in mkdocs and doxygen 2022-03-24 01:55:46 +03:00
Farook Al-Sammarraie
c199fa08dc
removed test changes 2022-03-21 13:57:13 +03:00
Farook Al-Sammarraie
8185e0d0cc
Merge branch 'master' into lowercase_methods 2022-03-21 13:49:23 +03:00
The-EDev
be45925731
fixed issue where parser methods were in all caps 2022-03-21 13:47:46 +03:00
Kinshuk Bairagi
77e68e45b6
Support for CROW_USE_LOCALTIMEZONE
define CROW_USE_LOCALTIMEZONE macro for explict optin for localtimezone in logs
2022-03-20 23:52:35 +05:30
Kinshuk Bairagi
ee4ccf755a
Add http 504 codes 2022-03-20 23:23:07 +05:30
The-EDev
a0e6e3756b
added set_global_base method to change the default mustache templates
directory
2022-03-18 13:55:27 +03:00
The-EDev
69feb9c226
Formatting 2022-03-16 21:15:18 +03:00
The-EDev
c858078b4e
Fixed test porblem 2022-03-16 18:45:31 +03:00
Farook Al-Sammarraie
c4bcec1999
Merge branch 'master' into run_async 2022-03-11 10:59:12 +03:00
The-EDev
af81ca9034
removed redundant methods (i() and d()) 2022-03-11 10:30:59 +03:00
The-EDev
c0062bd2e7
added run_async method
also added unit tests for #358
2022-03-10 15:44:39 +03:00
Farook Al-Sammarraie
b02e1b1a73
Merge branch 'master' into multipart_improvements 2022-03-10 09:55:35 +03:00
The-EDev
8224854b1d
Improved how multipart messages work
part headers are now in a map rather than a vector
added `get_part_by_name()`
parts and headers can be cast to integer or double (returns the value)
added a boundary to the default content-type (gets set to the request's
boundary if constructed from a request)
2022-03-10 09:52:27 +03:00
Vladislav
870028ec99
Merge branch 'master' into cors-middleware 2022-03-08 16:53:12 +03:00
Vladislav Oleshko
1c4416ef8d Fixes. Complete builder pattern. Add testcase 2022-03-08 16:33:08 +03:00
The-EDev
37940d2cc0
fixed multiple definition problem and added test to make sure it doesn't
happen again
2022-02-23 06:00:00 +03:00
Vladislav Oleshko
6432d4486d Add example and test 2022-02-22 17:38:51 +03:00
The-EDev
ac0c756209
clear new parser variables 2022-02-21 17:32:09 +03:00
Vladislav Oleshko
13d62841df CORS Middleware 2022-02-20 22:43:24 +03:00
The-EDev
4650b5ecde
formatting 2022-02-18 04:31:28 +03:00
The-EDev
9a876e9451
Made template render() function return a returnable instead of a string
Justification is for the content-type header to be set to HTML instead of
text.

Also added render_string() functions to replace the old methods.
2022-02-18 04:25:02 +03:00
Farook Al-Sammarraie
9db0e3b8fe
Merge branch 'master' into parser_optimization 2022-02-15 15:56:48 +03:00
Farook Al-Sammarraie
1c98bbb860
Merge branch 'master' into local-middleware 2022-02-14 22:17:19 +03:00
Vladislav Oleshko
b9dded57e8 Remove is_callable impl 2022-02-13 14:35:11 +03:00
Farook Al-Sammarraie
9b0f7fdb90
Update mustache.h 2022-02-11 18:26:26 +03:00
Farook Al-Sammarraie
ebef1caa08
Merge branch 'master' into master 2022-02-11 12:51:22 +03:00
Dominique Jacquel
787506350f Add unsafe/unsanitized load functions 2022-02-11 09:48:33 +00:00
The-EDev
4e2074dcb5
ran clang-format 2022-02-11 01:04:32 +03:00
The-EDev
9a7677bf1a
Applied changes from review
Also moved builtin_expect to utility.h (for use in sanitizer function)
2022-02-11 00:56:30 +03:00
Farook Al-Sammarraie
ab50fb3134
Merge branch 'master' into parser_optimization 2022-02-11 00:46:19 +03:00
The-EDev
9f6e099f10
fixed issue where content length was being set but body wasn't being sent 2022-02-09 20:57:12 +03:00
Vhuynh25
07a2422c63
changed output to null and changed warning message
also changed from <cmath> to <math.h>
2022-02-08 15:45:49 -08:00
Vhuynh25
7672f3a0f9
Merge branch 'CrowCpp:master' into master 2022-02-08 18:42:38 -05:00
Vladislav Oleshko
0b1eb12f60 Fix nonempty completion handler before middleware call 2022-02-08 21:15:25 +03:00
Vladislav Oleshko
80bc1cf00a Fix clang format 2022-02-08 20:18:49 +03:00
Vladislav Oleshko
4f4e12c91a Add CROW_MIDDLEWARES macro 2022-02-08 20:11:02 +03:00
The-EDev
dcd2b0c318
format 2022-02-08 19:22:09 +03:00
The-EDev
6ad068494f
sanitize load_text() path 2022-02-08 19:14:55 +03:00
The-EDev
155cf759eb
fixed issue where absolute unix paths were not sanitized 2022-02-08 19:11:46 +03:00
Vhuynh25
c44fec82bf
added space to match clang format 2022-02-06 11:58:41 -08:00
The-EDev
175b004c26
code formatting (also disabled formatting where not applicable) 2022-02-06 22:29:46 +03:00
The-EDev
75b100527f
Merge branch 'refs/heads/master' into parser_optimization 2022-02-05 18:35:01 +03:00
The-EDev
4cdde73388
Optimized HTTP parser
Also (likely) fixed problem with streaming without keeping connection
alive
Also fixed problem with multipart hanging on request
Also updated TODO entries to indicate Writer
2022-02-05 18:15:19 +03:00
Vhuynh25
781a40bee1
fixed clang format 2022-02-03 09:07:54 -08:00
Vladislav Oleshko
5d6db06706 Add local middleware after handlers to request handler 2022-02-02 17:37:19 +03:00
Vien Huynh
c21ae7ea3e change NaN output warning message 2022-02-01 16:40:07 -05:00
Vien Huynh
a134e2b9ff fixed NaN handling errors 2022-02-01 15:31:09 -05:00
Vladislav Oleshko
69e9ad9c1e Run clang format 2022-02-01 23:21:07 +03:00
Vladislav Oleshko
e60714c0b2 Separate middleware for handlers 2022-02-01 22:49:41 +03:00
Vien Huynh
9af906dc21 fixed JSON outputting NaN and infinite values 2022-01-30 23:43:30 -05:00
Farook Al-Sammarraie
9689688193
Merge branch 'master' into json-crash 2022-01-29 11:39:10 +03:00
Thomas Neumann
3569c93984 defend against excessive recursion in json::load
Passing a deeply nested JSON structure to json::load leads to a crash
due to stack overflow. We handle this now gracefully by limiting the
maximum nesting depth to 10,000.

Test case:

https://github.com/nst/JSONTestSuite/blob/master/test_parsing/n_structure_100000_opening_arrays.json
2022-01-25 08:48:36 +01:00
Thomas Neumann
2a77083524 fix const correctness in template_t
Without locking we can safely share only const objects between threads.
crow::mustache::template_t will typically be loaded once and then
reused many times across threads. Unfortunately the render() method
was not marked as const, even though it is const is practice. This commit
adds the missing const annotations to the methods involved.
2022-01-24 20:41:29 +01:00
Thomas Neumann
74e5fa8c87 improve sanitize_filename
The old implementation allocated a new string for every invocation, and
repeatedly scanned the string for occurences of the various Windows device
names. This commits resizes the original string instead if needed, and
detects all devices with a single pass.
2022-01-24 08:08:20 +01:00
Thomas Neumann
15085a9f95 avoid memory allocation in base64decode
Every single call to base64decode allocates a mapping table for all
base64 characters. This is quite wasteful, as the map is in fact static.
We could use a static variable here, but that would have unpleasant consequences
if we ever encounter input with non-valid base64 characters (which
implicitly modifies the map).

The number of character ranges for base64 is quite low (3, plus 4 exceptions),
thus we can simply check that explicitly in code instead of using a dynamic hash table.
2022-01-24 07:24:34 +01:00
The-EDev
e688cbd18e
Fixed another vulnerability in mustache file loading
and made the file sanitizer a copy-less function
2022-01-11 21:48:51 +03:00
The-EDev
0a16021442
Fix vulnrabilities in mustache and static 2022-01-11 20:27:41 +03:00
The-EDev
7aee13eee9
Changed the way concurrency is used
(it actually reflects the thread count properly)
2021-12-23 05:39:39 +03:00
The-EDev
77758e6241
Have concurrency represent the actual number threads used 2021-12-20 11:04:55 +03:00
Farook Al-Sammarraie
fa77468a88
Formatting 2021-12-17 09:45:50 +03:00
Farook Al-Sammarraie
0ef48e82bb
Fixed scoping issue
introduced by initializing `execute_result`
2021-12-17 09:30:58 +03:00
Farook Al-Sammarraie
790e34cea8
Merge branch 'master' into mustache_lambdas 2021-12-17 09:08:24 +03:00
Farook Al-Sammarraie
cca1d54ce5
took repeated code out of the if else statement 2021-12-17 09:07:46 +03:00
Farook Al-Sammarraie
ddc1f18a1e
Merge branch 'master' into issue-302 2021-12-17 08:11:57 +03:00
Mosolov Sergey
d59cda5677 Fixes issue 302
https://github.com/CrowCpp/Crow/issues/302
Escape only the invisible characters from 0 to 31 inclusive
Motivation: do not escape UTF8 encoding bytes
2021-12-17 08:47:00 +04:00
Navid Jalali
8de7ec2123 Missing inline specifier in http_status_str function definition fixed 2021-12-16 19:41:03 +03:30
Farook Al-Sammarraie
97baca78da
Merge branch 'master' into parser_upgrade 2021-12-16 12:53:24 +03:00
The-EDev
f6fd7dc85d
formatting, missing newline fixed 2021-12-11 02:38:30 +03:00
The-EDev
228e61d150
Added mustache lambda expansion 2021-12-10 05:17:25 +03:00
The-EDev
a1a4169d92
merge branch master 2021-12-10 05:12:24 +03:00
The-EDev
14acb50030
fixed server_ name 2021-12-08 19:57:10 +03:00
The-EDev
13768371a9
Fixed problems with signals 2021-12-08 05:21:03 +03:00
The-EDev
e110cf4856
upgraded parser from 2.3.0 to 2.9.4 2021-12-07 22:21:33 +03:00
Maxime BELUGUET
a997c2b69f Formatting 2021-12-07 14:15:11 +01:00
Maxime BELUGUET
dea78e02a0
Merge branch 'master' into master 2021-12-07 14:12:29 +01:00
Maxime BELUGUET
95083c1c9e Improve pick_io_service_idx 2021-12-07 11:06:18 +01:00
Maxime BELUGUET
874b4d2da0
Apply suggestions from code review
Add debug verbosity

Co-authored-by: Farook Al-Sammarraie <farook@the-e-dev.com>
2021-12-07 10:58:40 +01:00
Farook Al-Sammarraie
63c8af74f7
Merge branch 'master' into gcc8-workaround 2021-12-04 14:34:58 +03:00
Florian Rupprecht
24d8a72a94
Update include/crow/app.h
Co-authored-by: Farook Al-Sammarraie <farook@the-e-dev.com>
2021-12-04 12:32:32 +01:00
Farook Al-Sammarraie
faa81ec4a5
Merge branch 'master' into auth_tutorial 2021-12-04 04:17:09 +03:00
Maxime BELUGUET
06332c46b8 Move queue length initialisation 2021-12-03 17:40:10 +01:00
Maxime BELUGUET
5825b55350 Move queue length decrementation, formatting 2021-12-03 17:33:40 +01:00
The-EDev
869bc53150
format 2021-12-03 07:05:10 +03:00
The-EDev
78c88bbbb7
Updated mime_types script:
Made script generated code format compliant
Added option to have the script download the source file directly
Added generation date

Also updated the header file to the latest nginx mime.types
2021-12-03 06:41:30 +03:00
The-EDev
94a2f942bc
changed comment style back to the original (doxygen did not work with the new style) 2021-12-03 06:39:23 +03:00
The-EDev
3c6c675a18
formatting 2021-12-02 20:38:04 +03:00
The-EDev
a0a5616d1c
Added missing buffer clears and removed no longer used method from response 2021-12-02 20:18:34 +03:00
The-EDev
bb48f95298
moved file sending to connection and added check_destroy to it 2021-12-02 15:36:52 +03:00
Maxime BELUGUET
31143b9f06 Fix atomic queue_length initialisation 2021-11-30 19:54:37 +01:00
Maxime BELUGUET
e6adb88d09 Merge branch 'master' of github.com:belugum/Crow 2021-11-30 19:22:34 +01:00
Maxime BELUGUET
47263de37f
Merge branch 'master' into master 2021-11-30 19:22:22 +01:00
Maxime BELUGUET
2607bf5791 Change += to ++, add queue length decrementation on error 2021-11-30 19:22:07 +01:00
Maxime BELUGUET
f8af9eb187 Formatting 2021-11-30 18:14:16 +01:00
Luca Schlecker
dc317ced93 logger: don't append std::endl to the message.
ILogHandler instances should take care of that.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-29 23:59:41 +01:00
Maxime BELUGUET
0f6043f60d Add basic load balancing #258 #182 2021-11-29 16:56:12 +01:00
Farook Al-Sammarraie
9c55181657
Merge branch 'master' into gcc8-workaround 2021-11-29 13:42:22 +03:00
Luca Schlecker
7e4f1494d2 improved lambda bracing by inlining only empty lambdas.
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-27 19:22:35 +01:00
Farook Al-Sammarraie
62b74a1c7a
Merge branch 'master' into gcc8-workaround 2021-11-27 18:14:44 +03:00
Farook Al-Sammarraie
ef396a7c88
Merge branch 'master' into clang-format 2021-11-27 18:14:24 +03:00
Florian Rupprecht
7ee13c4536 GCC 8 workaround compiler detection & error 2021-11-27 14:30:37 +01:00
The-EDev
03e59aa446
improved bracing rules, commented out clang-format 14 rule 2021-11-27 15:28:50 +03:00
Luca Schlecker
9e0bd8ddc7 logger: move prefix and timestamp logic inside the ILogHandler default
implementation.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-26 12:18:03 +01:00
Florian Rupprecht
df50e3390d Spelling 2021-11-25 15:16:34 +01:00
Florian Rupprecht
58e211355f Constrain and warn GCC 8 bug 2021-11-25 15:14:45 +01:00
The-EDev
7f4b7c8ff9
created new rules, used bot to enforce rules in PRs 2021-11-25 14:45:38 +03:00
Florian Rupprecht
7a0576546c GCC 8 workaround 2021-11-23 16:00:14 +01:00
The-EDev
65f8eb9e44
added macro to enforce ws spec and added 16/64 bit payload length unit tests for ws 2021-11-22 17:39:48 +03:00
The-EDev
5440489640
Added protocol to log URL when starting crow 2021-11-22 16:03:55 +03:00
Luca Schlecker
1fc5c566af remove unused ssl code.
Seems like a leftover from when https was first implemented.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-22 02:45:08 +01:00
Luca Schlecker
912bf47b6f fix faulty https redirection.
Crow would redirect to https if ssl is enabled, even if no ssl is being actively used.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-22 02:45:08 +01:00
Luca Schlecker
e5c7daccce remove every occurance of #define CROW_MAIN.
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-21 17:25:16 +01:00
Luca Schlecker
5823a5984e remove the need for #define CROW_MAIN.
This is achieved using the conts type qualifier as it gives internal linkage.
fixes #273

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-21 17:25:16 +01:00
Luca Schlecker
250c793c48 http_server: fix reordering warning.
The introduced `timeout_` variable was initialized in a different order than the member initializer list suggested.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-21 15:45:46 +01:00
Luca Schlecker
118c992e0d task_timer: align comment style with Crow's.
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-21 15:45:40 +01:00
Luca Schlecker
6458184e8f task_timer: rename set_timeout to schedule.
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-20 17:03:58 +01:00
Luca Schlecker
de92d28f29 replace dumb_timer_queue with new task_timer.
fixes #264, lays ground for #273 and #257.

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-11-19 18:55:10 +01:00
Florian Rupprecht
5bb7fac016 Get app port 2021-11-14 13:04:19 +01:00
The-EDev
fd6de9bc05
Added functionality to close websocket connections before the app is
terminated.
This is incomplete and needs more work.
2021-11-06 06:06:18 +03:00
Farook Al-Sammarraie
2dc07aaa7e
Merge branch 'master' into feature/cpp20Support 2021-11-03 20:07:59 +03:00
Farook Al-Sammarraie
2e7d5f30f8
Merge branch 'master' into http09_get_only 2021-11-02 21:15:05 +03:00
Farook Al-Sammarraie
05a4b82bd5
Merge branch 'master' into http09_get_only 2021-11-02 00:00:03 +03:00