Commit Graph

425 Commits

Author SHA1 Message Date
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
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
The-EDev
85e85c3e64
allow remote IP to be accessed from websocket object 2021-11-01 23:57:21 +03:00
The-EDev
ed8d1ebaaa
Added checks for GET on HTTP/0.9 and any other errors
Earlier behavior only checked whether every byte was parsed, which isn't
ideal

Signed-off-by: The-EDev <farook@the-e-dev.com>
2021-11-01 12:02:25 +03:00
Leon De Andrade
06e665ec93 Cpp17 flag for msvc 2021-10-31 20:25:11 +01:00
Leon De Andrade
aa5211d76d Use invoke_result for C++20 2021-10-31 19:19:44 +01:00
The-EDev
576f90a0e4 Added Base64 decoder function and Base 64 unit tests 2021-10-31 02:50:19 +03:00
Farook
eefe8f62bf made it so that workarounds would only run if the user is on an apple machine 2021-10-22 14:27:10 +03:00
Luca Schlecker
7f7eac95a6
Merge branch 'master' into fix_macos 2021-10-14 10:36:03 +02:00
The-EDev
20c7720f72 Made crow's streaming threshold changeable through app.stream_threshold (I also added a getter for it to avoid sending it to the server then the connection) 2021-10-12 15:35:08 +03:00
The-EDev
efd55597f0 changed json and app code (relating to blueprints and initializer list)
also snuck in some guide updates
2021-10-10 14:42:36 +03:00
Farook Al-Sammarraie
72e33c743e
Merge branch 'master' into revamped_setup 2021-10-02 17:29:07 +03:00
The-EDev
ce1cc7b2b2 replaced http_connection.h integers with enum values 2021-10-02 17:11:19 +03:00
Farook Al-Sammarraie
de9e860771
Merge branch 'master' into revamped_setup 2021-10-01 11:34:55 +03:00
The-EDev
a031fb6c8e added status codes enum 2021-09-30 20:38:23 +03:00
Zhavok
1081d25a0f some status codes removed 2021-09-30 11:46:00 +02:00
Zhavok
db6ab441b4 missing http status codes added 2021-09-29 19:30:59 +02:00
The-EDev
b3638a3b83 Merge remote-tracking branch 'refs/remotes/origin/revamped_setup'
Conflicts:
	.drone.yml
2021-09-27 19:04:01 +03:00
Luca Schlecker
3c9e5d1e1d enable compression after first use of 'use_compression'. 2021-08-31 18:14:05 +02:00
Luca Schlecker
21c872e771 Revert "defining CROW_ENABLE_SSL disables non SSL code"
This reverts commit 10f3238ffc.
2021-08-31 18:14:05 +02:00
hg333
9546058604 added another constructor with status-code 2021-08-29 16:36:13 +05:30
hg333
b0e84a8c80 added custom type support 2021-08-29 12:19:18 +05:30
Luca Schlecker
823e891572 fix routing on windows. 2021-08-24 17:06:21 +02:00
Farook Al-Sammarraie
ddca7b5924
Merge branch 'master' into catchall_codes 2021-08-21 14:41:14 +03:00
The-EDev
db08b5a11d further simplified BP search code & made error_message const 2021-08-21 14:35:59 +03:00
The-EDev
10f3238ffc defining CROW_ENABLE_SSL disables non SSL code 2021-08-21 05:19:51 +03:00
The-EDev
576690bf14 Made catchall work with 404 or 405 errors
snuck in a fix for release.py where version name wouldn't change
also snuck in slight improvement in finding blueprint (removed extra if statement)
2021-08-21 04:49:17 +03:00
The-EDev
f5338260bb several changes:
added json list in a similar fashion to json object
renamed object_type to object
updated readme, index.html, and json.md to include objects and lists
updated examples to be slightly cleaner and include lists
replaced instances of json object (std::map and such) with the short version (object)
accurate floating point number dumping (`6.0` instead of `6`) while taking 1/30th of the time (29 microseconds saved)
added json list testing
snuck in utf-8 middleware warning fix
snuck in twitter card style for crowcpp.org site (makes social media cards look way better with a large image)
2021-08-20 03:57:21 +03:00
Farook Al-Sammarraie
84878ae4b1
Merge branch 'master' into ssl_test 2021-08-18 13:13:29 +03:00
Lucas David
49b020b9aa
Merge branch 'master' into feature-#189 2021-08-16 14:51:14 +02:00
The-EDev
17819e6571 Added middleware to automatically use utf-8 if no content-type is in the response 2021-08-15 15:28:26 +03:00
Farook Al-Sammarraie
fe52a2b117
Merge branch 'master' into feature-#189 2021-08-14 17:19:42 +03:00
himanshu007-creator
6ebea5ca77 remoteIpAddress 2021-08-14 18:58:23 +05:30
Himanshu
0f2b231448
Update http_request.h
CamelCase changed to snake_case
2021-08-14 18:01:19 +05:30
Lucas David
1e52b0182d ~ Corrected code as mentionned in review comments. 2021-08-11 22:25:58 +02:00
Lucas David
8f10f92627
Merge branch 'master' into feature-#189 2021-08-11 21:57:54 +02:00
Lucas David
df41cbec49 ~ Replaced foreach character type unsigned char by auto to resolve issue #195. 2021-08-11 15:43:40 +02:00
Lucas David
235f2b9ef4 + Added (implicit) constructors for json "supported" types.
+ added corresponding tests.
+ Added json-map examples.
2021-08-09 14:32:51 +02:00
Lucas David
762af68306 + Added object constructor and assignment for json::wvalue and unit tests.
+ json::wvalue::wvalue(std::initializer_list<std::pair<std::string const, json::wvalue>>
  + json::wvalue::wvalue(std::[unordered_]map<std::string, json::wvalue> const&)
  + json::wvalue::wvalue(std::[unordered_]map<std::string, json::wvalue>&&)
  + json::wvalue::operator=(std::initializer_list<std::pair<std::string const, json::wvalue>>)
  + json::wvalue::operator=(std::[unordered_]map<std::string, json::wvalue> const&)
  + json::wvalue::operator=(std::[unordered_]map<std::string, json::wvalue>&&)
2021-08-09 14:32:51 +02:00
Farook Al-Sammarraie
62af482f7b
Merge branch 'master' into patch-1 2021-08-07 03:24:26 +03:00
Dan Kersten
e6b36c3c03 Eliminate extern-initializer warning 2021-08-06 22:28:13 +01:00
Mustafa Mahmoud
d5c1b54918
Replace HTTPMethod::GET with HTTPMethod::Get 2021-08-06 19:01:13 +02:00
Farook Al-Sammarraie
8039b2eab9
Merge branch 'master' into blueprints 2021-08-05 19:54:02 +03:00
The-EDev
0588471d6d fixed extern constexpr problem 2021-08-05 19:53:52 +03:00
The-EDev
9418c39a92 fixed problem where using multiple files caused an error because you can't have extern constexpr 2021-08-05 17:01:03 +03:00
The-EDev
1474fbec33 used constant 0xffff in more places, used .empty(), and split the if statement into a method. 2021-08-04 23:58:38 +03:00
The-EDev
2def62bd4a removed unnecessary code / added constexpr for max bp id 2021-08-03 12:46:41 +03:00
Farook Al-Sammarraie
2d65f71de8
Merge branch 'master' into blueprints 2021-07-30 13:15:44 +03:00
The-EDev
addcce9e93 small fixes, optimizations, and documentation 2021-07-30 13:09:01 +03:00
The-EDev
e713ad54cb added unit test, moved macros to app.h, and fixed bug where "bp_prefix2" would be considered a child of "bp_prefix" even if it's not 2021-07-28 22:31:08 +03:00
Lucas David
1bb5e0ac63 + auto to_read = static_cast<std::uint64_t>(buffer_.size());
~ if (remaining_length_ < to_read)
~   to_read = remaining_length_;
+ adaptor_.socket().async_read_some(boost::asio::buffer(buffer_, static_cast<std::size_t>(to_read))
- size_t to_read = buffer_.size();
~ if (remaining_length_ < to_read)
~   to_read = remaining_length_;
- adaptor_.socket().async_read_some( boost::asio::buffer(buffer_, to_read)

~ Changed 'to_read' from [std::size_t] to [std::uint64_t],
  hence when 'remaining_length_' [std::uint64_t] is assigned in 'to_read' no data is lossed.
  When boost::asio::buffer is created 'to_read' is casted back to [std::size_t] explicitly truncating data.
  It seems to be the correct behavior to choose fixed 'network side' types.
2021-07-27 17:04:54 +02:00
Lucas David
6aa5dba579 + buf[1] += static_cast<char>(size);
- buf[1] += size;

~ Warning was triggered by 'size' being std::size_t and lossing data by implicit casting to a narrower type.
  This behavior seems correct, then we can explicit cast it.
2021-07-27 15:39:51 +02:00
The-EDev
06c4829ca7 implemented all blueprint features 2021-07-27 10:52:49 +03:00
The-EDev
27fe952a0c Merge branch 'master' 2021-07-20 11:00:09 +03:00
The-EDev
6d6fbe2385 removed unnecessary boolean 2021-07-19 00:01:20 +03:00
The-EDev
32d88725bd used CROW_LOG_DEBUG instead of std::cout (which was used to rapidly test the trie outside crow) 2021-07-10 23:14:38 +03:00
The-EDev
341a9b7fbe Re-implemented Trie 2021-07-10 22:45:47 +03:00
The-EDev
ea597d804a blueprint specific templates directory now supported 2021-07-07 15:51:04 +03:00
Farook Al-Sammarraie
da9f2e4531
Merge branch 'master' into release_script 2021-07-06 20:08:59 +03:00
Igor Mróz
3839a4a8e5
Add CROW_MAIN ifdef to VERSION variable. Move it to namespace. 2021-07-06 19:07:34 +02:00
The-EDev
85e4525d67 added custom static directory capability to blueprints (the endpoint remains "<prefix>/static/<filename>") 2021-07-06 01:53:32 +03:00
The-EDev
321f9c7fe6 Merge branch 'master' 2021-07-06 01:51:50 +03:00
The-EDev
165c72f56c fixed issue where disabling crow static directory would also disable all other routes 2021-07-05 12:18:00 +03:00
The-EDev
c46af69f41 Added basic blueprint support (registration and prefix) 2021-07-05 12:14:31 +03:00
The-EDev
6df5c94fd9 basic lambda support added (no expansion / blocks) 2021-07-03 23:28:52 +03:00
Igor Mróz
1d270fae19
Add release script. Change server name to use release version to build name. 2021-07-03 22:02:32 +02:00
Luca Schlecker
0593f42522 http_response: fix move assign operator not moving file_info.
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
2021-06-28 18:08:57 +02:00
The-EDev
fc27f73f84 Bump server version to 0.3 2021-06-05 06:30:01 +03:00
The-EDev
ca31b85156 added CROW_ENABLE_COMPRESSION macro to enable zlib compression
This makes zlib dependency (which is quite problematic) optional
2021-06-03 17:12:20 +03:00
dspverden
5aa45f1ebc Changed to #ifndef in logging.h 2021-06-02 17:05:52 +02:00
Darius Tan
3bd1956e90 Change HTTPMethod::HEAD to HTTPMethod::Head, HTTPMethod::GET to
HTTPMethod::Get and HTTPMethod::OPTIONS to HTTPMethod::Options.

VS2019 error:
enum "crow::HTTPMethod" has no member "HEAD"
enum "crow::HTTPMethod" has no member "GET"
enum "crow::HTTPMethod" has no member "OPTIONS"

See https://github.com/ipkn/crow/pull/307 for a similar issue.
2021-05-23 19:58:01 +12:00
Maxime BELUGUET
811ef62c6f Fix constness on json dump method #133 2021-05-18 18:10:39 +02:00
The-EDev
0e9b615c2b fixed typos 2021-05-13 13:30:48 +03:00
The-EDev
f39b9ddce7 Quality of life improvements
Added pop() method to query_string, same as get(), but removes the item from the querystring
Added std::string() operator to json::rvalue (allows std::string(json["abc"]), which returns any value that isn't a container to string)
Added lo() method to json::rvalue, returns a vector of json::rvalue containing whatever a json object or list has (difference being a list has no keys)
Added keys() method to json::rvalue, returns a vector of std::string containing the keys of a json object
Made json::wvalue use either std::map or std::unordered_map instead of just std::unordered_map
Added copy constructor to json::wvalue
Added size() method to json::wvalue, returns 1 or the size of the json list.
Added constructor to create json::wvalue from std::vector
Added keys() method to query_string
Documented query_string and improved json doc
Made tests and examples for all the additions
2021-05-12 15:45:55 +03:00
The-EDev
798f190fc8 added initial ssl testing 2021-04-17 02:33:35 +03:00
The-EDev
5b7b066c68 fixed typo and incorrect type in assert error 2021-04-14 04:55:27 +03:00
Farook Al-Sammarraie
5f91587479
Merge branch 'master' into catch_all 2021-04-12 23:45:07 +03:00
The-EDev
738abdbd96 fixed issue where response is logged twice 2021-04-12 20:11:03 +03:00
Farook Al-Sammarraie
4aae614297
Merge branch 'master' into catch_all 2021-04-12 10:49:29 +03:00
The-EDev
16ae11a4e3 updated catchall to use references instead of pointers 2021-04-12 10:41:55 +03:00
The-EDev
f779a0f8a4 changed catchall to fit with the rest of crow
the macro is similar to CROW_ROUTE, added example to cmake, added unit test, and documentation
2021-04-12 08:25:09 +03:00
Tibbel
7ad1b79b7a
Delete example_catchall.cpp 2021-04-05 10:21:58 +02:00
Tibbel
97ef2945ed
CROW_CATCHALL #endif if moved
CROW_CATCHALL #endif if moved
2021-04-05 10:14:38 +02:00
Tibbel
5b880cef49
Add a catch-all handler 2nd version
Here is the modified catchall-function
example added
the code moved to routing.h
only the setter remained in app.h
the integer return is removed
i personally don't need the default parameters:
without crow::response the catchall can take no effect
and without crow::request you know nothing about the request
i only imagine one case, this is to set custom error pages.
so i don't thing default parameters have any big benefit here.
"#ifdef CROW_CATCHALL" was only for me, to find my own modifications feel free to replace it
2021-04-05 09:44:35 +02:00
The-EDev
111bef9deb use actual ASIO port instead of the local port variable
this is useful when using port 0 to have the OS provide a free port
2021-04-04 08:09:59 +03:00
The-EDev
b837877715 updated head and no_length variable names 2021-04-03 13:48:36 +03:00
The-EDev
5f68479ee5 fixed small merge issue 2021-04-03 06:40:14 +03:00
Farook Al-Sammarraie
1654acbfd0
Merge branch 'master' into HEAD_and_OPTIONS 2021-04-03 06:31:45 +03:00
The-EDev
33e8631676 Added Content-Length header back to HEAD response.
The reason for removing it was an issue with Curl rather than how HEAD should be handled.
2021-04-03 06:21:18 +03:00
The-EDev
ec566f87ef added tests and fixed small issues
moved body handling to Response.end() and fixed a bug where a 404 was not returned on a route that doesn't exist
2021-04-03 06:00:23 +03:00
The-EDev
06226b86a7 implemented proper HEAD handling, implemented OPTIONS handling 2021-04-03 05:33:40 +03:00