| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -224,6 +224,14 @@ jobs: | |||
| 224 | 224 | cc-compiler: g++-7 | |
| 225 | 225 | debug: nodebug | |
| 226 | 226 | coverage: nocoverage | |
| 227 | + - test-group: extra | ||
| 228 | + os: ubuntu-latest | ||
| 229 | + build-type: lint | ||
| 230 | + compiler-family: gcc | ||
| 231 | + c-compiler: gcc-7 | ||
| 232 | + cc-compiler: g++-7 | ||
| 233 | + debug: debug | ||
| 234 | + coverage: nocoverage | ||
| 227 | 235 | steps: | |
| 228 | 236 | - name: Checkout repository | |
| 229 | 237 | uses: actions/checkout@v2 | |
@@ -258,6 +266,10 @@ jobs: | |||
| 258 | 266 | - name: Install valgrind if needed | |
| 259 | 267 | run: sudo apt-get install valgrind valgrind-dbg | |
| 260 | 268 | if: ${{ matrix.build-type == 'valgrind' && matrix.os == 'ubuntu-latest' }} | |
| 269 | + | ||
| 270 | + - name: Install cpplint if needed | ||
| 271 | + run: sudo pip3 install cpplint ; | ||
| 272 | + if: ${{ matrix.build-type == 'lint' && matrix.os == 'ubuntu-latest' }} | ||
| 261 | 273 | ||
| 262 | 274 | - name: Install IWYU dependencies if needed | |
| 263 | 275 | run: | | |
@@ -357,6 +369,10 @@ jobs: | |||
| 357 | 369 | run: sudo ldconfig ; | |
| 358 | 370 | if: ${{ matrix.os == 'ubuntu-latest' }} | |
| 359 | 371 | ||
| 372 | + - name: Run cpplint on code | ||
| 373 | + run: cpplint --extensions=cpp,hpp --headers=hpp --recursive . ; | ||
| 374 | + if: ${{ matrix.build-type == 'lint' && matrix.os == 'ubuntu-latest' }} | ||
| 375 | + | ||
| 360 | 376 | - name: Run libhttpserver configure | |
| 361 | 377 | run: | | |
| 362 | 378 | # Set memory check flags. They need to stay in step as env variables don't propagate across steps. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + linelength=200 | ||
| 2 | + headers=hpp | ||
| 3 | + extensions=cpp,hpp | ||
| 4 | + filter=-test/littletest.hpp | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,7 @@ | |||
| 1 | + Sun Mar 07 20:02:10 2021 -0800 | ||
| 2 | + Cleaned code to support cpplint and extra warnings. | ||
| 3 | + Use pointers in place of non-const references. | ||
| 4 | + | ||
| 1 | 5 | Thu Feb 25 20:27:12 2021 -0800 | |
| 2 | 6 | Simplified dependency management for libmicrohttpd | |
| 3 | 7 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,8 +21,8 @@ | |||
| 21 | 21 | ||
| 22 | 22 | AC_PREREQ(2.57) | |
| 23 | 23 | m4_define([libhttpserver_MAJOR_VERSION],[0])dnl | |
| 24 | - m4_define([libhttpserver_MINOR_VERSION],[18])dnl | ||
| 25 | - m4_define([libhttpserver_REVISION],[2])dnl | ||
| 24 | + m4_define([libhttpserver_MINOR_VERSION],[19])dnl | ||
| 25 | + m4_define([libhttpserver_REVISION],[0])dnl | ||
| 26 | 26 | m4_define([libhttpserver_PKG_VERSION],[libhttpserver_MAJOR_VERSION.libhttpserver_MINOR_VERSION.libhttpserver_REVISION])dnl | |
| 27 | 27 | m4_define([libhttpserver_LDF_VERSION],[libhttpserver_MAJOR_VERSION:libhttpserver_MINOR_VERSION:libhttpserver_REVISION])dnl | |
| 28 | 28 | AC_INIT([libhttpserver], libhttpserver_PKG_VERSION, [electrictwister2000@gmail.com]) | |
@@ -194,8 +194,8 @@ AM_LDFLAGS="-lstdc++" | |||
| 194 | 194 | ||
| 195 | 195 | if test x"$debugit" = x"yes"; then | |
| 196 | 196 | AC_DEFINE([DEBUG],[],[Debug Mode]) | |
| 197 | - AM_CXXFLAGS="$AM_CXXFLAGS -DDEBUG -g -Wall -Wno-uninitialized -O0" | ||
| 198 | - AM_CFLAGS="$AM_CXXFLAGS -DDEBUG -g -Wall -Wno-uninitialized -O0" | ||
| 197 | + AM_CXXFLAGS="$AM_CXXFLAGS -DDEBUG -g -Wall -Wextra -Werror -pedantic -std=c++14 -Wno-unused-command-line-argument -O0" | ||
| 198 | + AM_CFLAGS="$AM_CXXFLAGS -DDEBUG -g -Wall -Wextra -Werror -pedantic -Wno-unused-command-line-argument -O0" | ||
| 199 | 199 | else | |
| 200 | 200 | AC_DEFINE([NDEBUG],[],[No-debug Mode]) | |
| 201 | 201 | AM_CXXFLAGS="$AM_CXXFLAGS -O3" | |
@@ -270,6 +270,7 @@ AC_SUBST(EXT_LIB_PATH) | |||
| 270 | 270 | AC_SUBST(EXT_LIBS) | |
| 271 | 271 | ||
| 272 | 272 | AC_CONFIG_FILES([test/test_content:test/test_content]) | |
| 273 | + AC_CONFIG_FILES([test/test_content_empty:test/test_content_empty]) | ||
| 273 | 274 | AC_CONFIG_FILES([test/cert.pem:test/cert.pem]) | |
| 274 | 275 | AC_CONFIG_FILES([test/key.pem:test/key.pem]) | |
| 275 | 276 | AC_CONFIG_FILES([test/test_root_ca.pem:test/test_root_ca.pem]) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,17 +20,15 @@ | |||
| 20 | 20 | ||
| 21 | 21 | #include <httpserver.hpp> | |
| 22 | 22 | ||
| 23 | - using namespace httpserver; | ||
| 24 | - | ||
| 25 | - class hello_world_resource : public http_resource { | ||
| 26 | - public: | ||
| 27 | - const std::shared_ptr<http_response> render(const http_request&) { | ||
| 28 | - return std::shared_ptr<http_response>(new string_response("Hello, World!")); | ||
| 29 | - } | ||
| 23 | + class hello_world_resource : public httpserver::http_resource { | ||
| 24 | + public: | ||
| 25 | + const std::shared_ptr<httpserver::http_response> render(const httpserver::http_request&) { | ||
| 26 | + return std::shared_ptr<httpserver::http_response>(new httpserver::string_response("Hello, World!")); | ||
| 27 | + } | ||
| 30 | 28 | }; | |
| 31 | 29 | ||
| 32 | - int main(int argc, char** argv) { | ||
| 33 | - webserver ws = create_webserver(8080); | ||
| 30 | + int main() { | ||
| 31 | + httpserver::webserver ws = httpserver::create_webserver(8080); | ||
| 34 | 32 | ||
| 35 | 33 | hello_world_resource hwr; | |
| 36 | 34 | hwr.disallow_all(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,23 +20,19 @@ | |||
| 20 | 20 | ||
| 21 | 21 | #include <httpserver.hpp> | |
| 22 | 22 | ||
| 23 | - using namespace httpserver; | ||
| 24 | - | ||
| 25 | - class user_pass_resource : public httpserver::http_resource | ||
| 26 | - { | ||
| 27 | - public: | ||
| 28 | - const std::shared_ptr<http_response> render_GET(const http_request& req) | ||
| 29 | - { | ||
| 30 | - if (req.get_user() != "myuser" || req.get_pass() != "mypass") | ||
| 31 | - { | ||
| 32 | - return std::shared_ptr<basic_auth_fail_response>(new basic_auth_fail_response("FAIL", "test@example.com")); | ||
| 33 | - } | ||
| 34 | - return std::shared_ptr<string_response>(new string_response(req.get_user() + " " + req.get_pass(), 200, "text/plain")); | ||
| 35 | - } | ||
| 23 | + class user_pass_resource : public httpserver::http_resource { | ||
| 24 | + public: | ||
| 25 | + const std::shared_ptr<httpserver::http_response> render_GET(const httpserver::http_request& req) { | ||
| 26 | + if (req.get_user() != "myuser" || req.get_pass() != "mypass") { | ||
| 27 | + return std::shared_ptr<httpserver::basic_auth_fail_response>(new httpserver::basic_auth_fail_response("FAIL", "test@example.com")); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + return std::shared_ptr<httpserver::string_response>(new httpserver::string_response(req.get_user() + " " + req.get_pass(), 200, "text/plain")); | ||
| 31 | + } | ||
| 36 | 32 | }; | |
| 37 | 33 | ||
| 38 | - int main(int argc, char** argv) { | ||
| 39 | - webserver ws = create_webserver(8080); | ||
| 34 | + int main() { | ||
| 35 | + httpserver::webserver ws = httpserver::create_webserver(8080); | ||
| 40 | 36 | ||
| 41 | 37 | user_pass_resource hwr; | |
| 42 | 38 | ws.register_resource("/hello", &hwr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,23 @@ | |||
| 1 | + /* | ||
| 2 | + This file is part of libhttpserver | ||
| 3 | + Copyright (C) 2011, 2012, 2013, 2014, 2015 Sebastiano Merlino | ||
| 4 | + | ||
| 5 | + This library is free software; you can redistribute it and/or | ||
| 6 | + modify it under the terms of the GNU Lesser General Public | ||
| 7 | + License as published by the Free Software Foundation; either | ||
| 8 | + version 2.1 of the License, or (at your option) any later version. | ||
| 9 | + | ||
| 10 | + This library is distributed in the hope that it will be useful, | ||
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | + Lesser General Public License for more details. | ||
| 14 | + | ||
| 15 | + You should have received a copy of the GNU Lesser General Public | ||
| 16 | + License along with this library; if not, write to the Free Software | ||
| 17 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
| 18 | + USA | ||
| 19 | + */ | ||
| 20 | + | ||
| 1 | 21 | #include <cstdlib> | |
| 2 | 22 | #include <memory> | |
| 3 | 23 | ||
@@ -6,31 +26,29 @@ | |||
| 6 | 26 | #define PATH "/plaintext" | |
| 7 | 27 | #define BODY "Hello, World!" | |
| 8 | 28 | ||
| 9 | - using namespace httpserver; | ||
| 10 | - | ||
| 11 | - class hello_world_resource : public http_resource { | ||
| 12 | - public: | ||
| 13 | - hello_world_resource(const std::shared_ptr<http_response>& resp): | ||
| 14 | - resp(resp) | ||
| 15 | - { | ||
| 16 | - } | ||
| 29 | + class hello_world_resource : public httpserver::http_resource { | ||
| 30 | + public: | ||
| 31 | + explicit hello_world_resource(const std::shared_ptr<httpserver::http_response>& resp): | ||
| 32 | + resp(resp) { | ||
| 33 | + } | ||
| 17 | 34 | ||
| 18 | - const std::shared_ptr<http_response> render(const http_request&) { | ||
| 19 | - return resp; | ||
| 20 | - } | ||
| 35 | + const std::shared_ptr<httpserver::http_response> render(const httpserver::http_request&) { | ||
| 36 | + return resp; | ||
| 37 | + } | ||
| 21 | 38 | ||
| 22 | - private: | ||
| 23 | - std::shared_ptr<http_response> resp; | ||
| 39 | + private: | ||
| 40 | + std::shared_ptr<httpserver::http_response> resp; | ||
| 24 | 41 | }; | |
| 25 | 42 | ||
| 26 | - int main(int argc, char** argv) | ||
| 27 | - { | ||
| 28 | - webserver ws = create_webserver(atoi(argv[1])) | ||
| 29 | - .start_method(http::http_utils::INTERNAL_SELECT) | ||
| 43 | + int main(int argc, char** argv) { | ||
| 44 | + std::ignore = argc; | ||
| 45 | + | ||
| 46 | + httpserver::webserver ws = httpserver::create_webserver(atoi(argv[1])) | ||
| 47 | + .start_method(httpserver::http::http_utils::INTERNAL_SELECT) | ||
| 30 | 48 | .tcp_nodelay() | |
| 31 | 49 | .max_threads(atoi(argv[2])); | |
| 32 | 50 | ||
| 33 | - std::shared_ptr<http_response> hello = std::shared_ptr<http_response>(new string_response(BODY, 200)); | ||
| 51 | + std::shared_ptr<httpserver::http_response> hello = std::shared_ptr<httpserver::http_response>(new httpserver::string_response(BODY, 200)); | ||
| 34 | 52 | hello->with_header("Server", "libhttpserver"); | |
| 35 | 53 | ||
| 36 | 54 | hello_world_resource hwr(hello); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,23 @@ | |||
| 1 | + /* | ||
| 2 | + This file is part of libhttpserver | ||
| 3 | + Copyright (C) 2011, 2012, 2013, 2014, 2015 Sebastiano Merlino | ||
| 4 | + | ||
| 5 | + This library is free software; you can redistribute it and/or | ||
| 6 | + modify it under the terms of the GNU Lesser General Public | ||
| 7 | + License as published by the Free Software Foundation; either | ||
| 8 | + version 2.1 of the License, or (at your option) any later version. | ||
| 9 | + | ||
| 10 | + This library is distributed in the hope that it will be useful, | ||
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | + Lesser General Public License for more details. | ||
| 14 | + | ||
| 15 | + You should have received a copy of the GNU Lesser General Public | ||
| 16 | + License along with this library; if not, write to the Free Software | ||
| 17 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
| 18 | + USA | ||
| 19 | + */ | ||
| 20 | + | ||
| 1 | 21 | #include <cstdlib> | |
| 2 | 22 | #include <memory> | |
| 3 | 23 | ||
@@ -6,30 +26,28 @@ | |||
| 6 | 26 | #define PATH "/plaintext" | |
| 7 | 27 | #define BODY "Hello, World!" | |
| 8 | 28 | ||
| 9 | - using namespace httpserver; | ||
| 10 | - | ||
| 11 | - class hello_world_resource : public http_resource { | ||
| 12 | - public: | ||
| 13 | - hello_world_resource(const std::shared_ptr<http_response>& resp): | ||
| 14 | - resp(resp) | ||
| 15 | - { | ||
| 16 | - } | ||
| 29 | + class hello_world_resource : public httpserver::http_resource { | ||
| 30 | + public: | ||
| 31 | + explicit hello_world_resource(const std::shared_ptr<httpserver::http_response>& resp): | ||
| 32 | + resp(resp) { | ||
| 33 | + } | ||
| 17 | 34 | ||
| 18 | - const std::shared_ptr<http_response> render(const http_request&) { | ||
| 19 | - return resp; | ||
| 20 | - } | ||
| 35 | + const std::shared_ptr<httpserver::http_response> render(const httpserver::http_request&) { | ||
| 36 | + return resp; | ||
| 37 | + } | ||
| 21 | 38 | ||
| 22 | - private: | ||
| 23 | - std::shared_ptr<http_response> resp; | ||
| 39 | + private: | ||
| 40 | + std::shared_ptr<httpserver::http_response> resp; | ||
| 24 | 41 | }; | |
| 25 | 42 | ||
| 26 | - int main(int argc, char** argv) | ||
| 27 | - { | ||
| 28 | - webserver ws = create_webserver(atoi(argv[1])) | ||
| 29 | - .start_method(http::http_utils::INTERNAL_SELECT) | ||
| 43 | + int main(int argc, char** argv) { | ||
| 44 | + std::ignore = argc; | ||
| 45 | + | ||
| 46 | + httpserver::webserver ws = httpserver::create_webserver(atoi(argv[1])) | ||
| 47 | + .start_method(httpserver::http::http_utils::INTERNAL_SELECT) | ||
| 30 | 48 | .max_threads(atoi(argv[2])); | |
| 31 | 49 | ||
| 32 | - std::shared_ptr<http_response> hello = std::shared_ptr<http_response>(new string_response(BODY, 200)); | ||
| 50 | + std::shared_ptr<httpserver::http_response> hello = std::shared_ptr<httpserver::http_response>(new httpserver::string_response(BODY, 200)); | ||
| 33 | 51 | hello->with_header("Server", "libhttpserver"); | |
| 34 | 52 | ||
| 35 | 53 | hello_world_resource hwr(hello); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,23 @@ | |||
| 1 | + /* | ||
| 2 | + This file is part of libhttpserver | ||
| 3 | + Copyright (C) 2011, 2012, 2013, 2014, 2015 Sebastiano Merlino | ||
| 4 | + | ||
| 5 | + This library is free software; you can redistribute it and/or | ||
| 6 | + modify it under the terms of the GNU Lesser General Public | ||
| 7 | + License as published by the Free Software Foundation; either | ||
| 8 | + version 2.1 of the License, or (at your option) any later version. | ||
| 9 | + | ||
| 10 | + This library is distributed in the hope that it will be useful, | ||
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | + Lesser General Public License for more details. | ||
| 14 | + | ||
| 15 | + You should have received a copy of the GNU Lesser General Public | ||
| 16 | + License along with this library; if not, write to the Free Software | ||
| 17 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
| 18 | + USA | ||
| 19 | + */ | ||
| 20 | + | ||
| 1 | 21 | #include <cstdlib> | |
| 2 | 22 | #include <memory> | |
| 3 | 23 | ||
@@ -6,29 +26,27 @@ | |||
| 6 | 26 | #define PATH "/plaintext" | |
| 7 | 27 | #define BODY "Hello, World!" | |
| 8 | 28 | ||
| 9 | - using namespace httpserver; | ||
| 10 | - | ||
| 11 | - class hello_world_resource : public http_resource { | ||
| 12 | - public: | ||
| 13 | - hello_world_resource(const std::shared_ptr<http_response>& resp): | ||
| 14 | - resp(resp) | ||
| 15 | - { | ||
| 16 | - } | ||
| 29 | + class hello_world_resource : public httpserver::http_resource { | ||
| 30 | + public: | ||
| 31 | + explicit hello_world_resource(const std::shared_ptr<httpserver::http_response>& resp): | ||
| 32 | + resp(resp) { | ||
| 33 | + } | ||
| 17 | 34 | ||
| 18 | - const std::shared_ptr<http_response> render(const http_request&) { | ||
| 19 | - return resp; | ||
| 20 | - } | ||
| 35 | + const std::shared_ptr<httpserver::http_response> render(const httpserver::http_request&) { | ||
| 36 | + return resp; | ||
| 37 | + } | ||
| 21 | 38 | ||
| 22 | - private: | ||
| 23 | - std::shared_ptr<http_response> resp; | ||
| 39 | + private: | ||
| 40 | + std::shared_ptr<httpserver::http_response> resp; | ||
| 24 | 41 | }; | |
| 25 | 42 | ||
| 26 | - int main(int argc, char** argv) | ||
| 27 | - { | ||
| 28 | - webserver ws = create_webserver(atoi(argv[1])) | ||
| 29 | - .start_method(http::http_utils::THREAD_PER_CONNECTION); | ||
| 43 | + int main(int argc, char** argv) { | ||
| 44 | + std::ignore = argc; | ||
| 45 | + | ||
| 46 | + httpserver::webserver ws = httpserver::create_webserver(atoi(argv[1])) | ||
| 47 | + .start_method(httpserver::http::http_utils::THREAD_PER_CONNECTION); | ||
| 30 | 48 | ||
| 31 | - std::shared_ptr<http_response> hello = std::shared_ptr<http_response>(new string_response(BODY, 200)); | ||
| 49 | + std::shared_ptr<httpserver::http_response> hello = std::shared_ptr<httpserver::http_response>(new httpserver::string_response(BODY, 200)); | ||
| 32 | 50 | hello->with_header("Server", "libhttpserver"); | |
| 33 | 51 | ||
| 34 | 52 | hello_world_resource hwr(hello); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,21 +22,19 @@ | |||
| 22 | 22 | ||
| 23 | 23 | #include <httpserver.hpp> | |
| 24 | 24 | ||
| 25 | - using namespace httpserver; | ||
| 26 | - | ||
| 27 | 25 | void custom_access_log(const std::string& url) { | |
| 28 | 26 | std::cout << "ACCESSING: " << url << std::endl; | |
| 29 | 27 | } | |
| 30 | 28 | ||
| 31 | - class hello_world_resource : public http_resource { | ||
| 32 | - public: | ||
| 33 | - const std::shared_ptr<http_response> render(const http_request&) { | ||
| 34 | - return std::shared_ptr<http_response>(new string_response("Hello, World!")); | ||
| 35 | - } | ||
| 29 | + class hello_world_resource : public httpserver::http_resource { | ||
| 30 | + public: | ||
| 31 | + const std::shared_ptr<httpserver::http_response> render(const httpserver::http_request&) { | ||
| 32 | + return std::shared_ptr<httpserver::http_response>(new httpserver::string_response("Hello, World!")); | ||
| 33 | + } | ||
| 36 | 34 | }; | |
| 37 | 35 | ||
| 38 | - int main(int argc, char** argv) { | ||
| 39 | - webserver ws = create_webserver(8080) | ||
| 36 | + int main() { | ||
| 37 | + httpserver::webserver ws = httpserver::create_webserver(8080) | ||
| 40 | 38 | .log_access(custom_access_log); | |
| 41 | 39 | ||
| 42 | 40 | hello_world_resource hwr; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments