GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add checks using cpplint (#209) · bcsgh/libhttpserver@6d1df06

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • verify-build.yml
  • CPPLINT.cfg
  • ChangeLog
  • configure.ac
  • examples
    • allowing_disallowing_methods.cpp
    • basic_authentication.cpp
    • benchmark_nodelay.cpp
    • benchmark_select.cpp
    • benchmark_threads.cpp
    • custom_access_log.cpp
    • custom_error.cpp
    • deferred_with_accumulator.cpp
    • digest_authentication.cpp
    • handlers.cpp
    • hello_with_get_arg.cpp
    • hello_world.cpp
    • minimal_deferred.cpp
    • minimal_file_response.cpp
    • minimal_hello_world.cpp
    • minimal_https.cpp
    • minimal_ip_ban.cpp
    • service.cpp
    • setting_headers.cpp
    • url_registration.cpp
  • src
    • basic_auth_fail_response.cpp
    • deferred_response.cpp
    • details
      • http_endpoint.cpp
    • digest_auth_fail_response.cpp
    • file_response.cpp
    • http_request.cpp
    • http_resource.cpp
    • http_response.cpp
    • http_utils.cpp
    • httpserver.hpp
    • httpserver
      • basic_auth_fail_response.hpp
      • create_webserver.hpp
      • deferred_response.hpp
      • details
        • http_endpoint.hpp
        • modded_request.hpp
      • digest_auth_fail_response.hpp
      • file_response.hpp
      • http_request.hpp
      • http_resource.hpp
      • http_response.hpp
      • http_utils.hpp
      • string_response.hpp
      • string_utilities.hpp
      • webserver.hpp
    • string_response.cpp
    • string_utilities.cpp
    • webserver.cpp
  • test
    • CPPLINT.cfg
    • integ
      • authentication.cpp
      • ban_system.cpp
      • basic.cpp
      • deferred.cpp
      • nodelay.cpp
      • threaded.cpp
      • ws_start_stop.cpp
    • littletest.hpp
    • test_content_empty
    • unit
      • http_endpoint_test.cpp
      • http_utils_test.cpp
      • string_utilities_test.cpp

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/verify-build.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/verify-build.yml
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ jobs:
224224
cc-compiler: g++-7
225225
debug: nodebug
226226
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
227235
steps:
228236
- name: Checkout repository
229237
uses: actions/checkout@v2
@@ -258,6 +266,10 @@ jobs:
258266
- name: Install valgrind if needed
259267
run: sudo apt-get install valgrind valgrind-dbg
260268
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' }}
261273

262274
- name: Install IWYU dependencies if needed
263275
run: |
@@ -357,6 +369,10 @@ jobs:
357369
run: sudo ldconfig ;
358370
if: ${{ matrix.os == 'ubuntu-latest' }}
359371

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+
360376
- name: Run libhttpserver configure
361377
run: |
362378
# Set memory check flags. They need to stay in step as env variables don't propagate across steps.
Collapse file

‎CPPLINT.cfg‎

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
linelength=200
2+
headers=hpp
3+
extensions=cpp,hpp
4+
filter=-test/littletest.hpp
Collapse file

‎ChangeLog‎

Copy file name to clipboardExpand all lines: ChangeLog
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
15
Thu Feb 25 20:27:12 2021 -0800
26
Simplified dependency management for libmicrohttpd
37

Collapse file

‎configure.ac‎

Copy file name to clipboardExpand all lines: configure.ac
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
AC_PREREQ(2.57)
2323
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
2626
m4_define([libhttpserver_PKG_VERSION],[libhttpserver_MAJOR_VERSION.libhttpserver_MINOR_VERSION.libhttpserver_REVISION])dnl
2727
m4_define([libhttpserver_LDF_VERSION],[libhttpserver_MAJOR_VERSION:libhttpserver_MINOR_VERSION:libhttpserver_REVISION])dnl
2828
AC_INIT([libhttpserver], libhttpserver_PKG_VERSION, [[email protected]])
@@ -194,8 +194,8 @@ AM_LDFLAGS="-lstdc++"
194194

195195
if test x"$debugit" = x"yes"; then
196196
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"
199199
else
200200
AC_DEFINE([NDEBUG],[],[No-debug Mode])
201201
AM_CXXFLAGS="$AM_CXXFLAGS -O3"
@@ -270,6 +270,7 @@ AC_SUBST(EXT_LIB_PATH)
270270
AC_SUBST(EXT_LIBS)
271271

272272
AC_CONFIG_FILES([test/test_content:test/test_content])
273+
AC_CONFIG_FILES([test/test_content_empty:test/test_content_empty])
273274
AC_CONFIG_FILES([test/cert.pem:test/cert.pem])
274275
AC_CONFIG_FILES([test/key.pem:test/key.pem])
275276
AC_CONFIG_FILES([test/test_root_ca.pem:test/test_root_ca.pem])
Collapse file

‎examples/allowing_disallowing_methods.cpp‎

Copy file name to clipboardExpand all lines: examples/allowing_disallowing_methods.cpp
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020

2121
#include <httpserver.hpp>
2222

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+
}
3028
};
3129

32-
int main(int argc, char** argv) {
33-
webserver ws = create_webserver(8080);
30+
int main() {
31+
httpserver::webserver ws = httpserver::create_webserver(8080);
3432

3533
hello_world_resource hwr;
3634
hwr.disallow_all();
Collapse file

‎examples/basic_authentication.cpp‎

Copy file name to clipboardExpand all lines: examples/basic_authentication.cpp
+11-15Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,19 @@
2020

2121
#include <httpserver.hpp>
2222

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", "[email protected]"));
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", "[email protected]"));
28+
}
29+
30+
return std::shared_ptr<httpserver::string_response>(new httpserver::string_response(req.get_user() + " " + req.get_pass(), 200, "text/plain"));
31+
}
3632
};
3733

38-
int main(int argc, char** argv) {
39-
webserver ws = create_webserver(8080);
34+
int main() {
35+
httpserver::webserver ws = httpserver::create_webserver(8080);
4036

4137
user_pass_resource hwr;
4238
ws.register_resource("/hello", &hwr);
Collapse file

‎examples/benchmark_nodelay.cpp‎

Copy file name to clipboardExpand all lines: examples/benchmark_nodelay.cpp
+36-18Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff 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+
121
#include <cstdlib>
222
#include <memory>
323

@@ -6,31 +26,29 @@
626
#define PATH "/plaintext"
727
#define BODY "Hello, World!"
828

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+
}
1734

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+
}
2138

22-
private:
23-
std::shared_ptr<http_response> resp;
39+
private:
40+
std::shared_ptr<httpserver::http_response> resp;
2441
};
2542

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)
3048
.tcp_nodelay()
3149
.max_threads(atoi(argv[2]));
3250

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));
3452
hello->with_header("Server", "libhttpserver");
3553

3654
hello_world_resource hwr(hello);
Collapse file

‎examples/benchmark_select.cpp‎

Copy file name to clipboardExpand all lines: examples/benchmark_select.cpp
+36-18Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff 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+
121
#include <cstdlib>
222
#include <memory>
323

@@ -6,30 +26,28 @@
626
#define PATH "/plaintext"
727
#define BODY "Hello, World!"
828

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+
}
1734

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+
}
2138

22-
private:
23-
std::shared_ptr<http_response> resp;
39+
private:
40+
std::shared_ptr<httpserver::http_response> resp;
2441
};
2542

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)
3048
.max_threads(atoi(argv[2]));
3149

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));
3351
hello->with_header("Server", "libhttpserver");
3452

3553
hello_world_resource hwr(hello);
Collapse file

‎examples/benchmark_threads.cpp‎

Copy file name to clipboardExpand all lines: examples/benchmark_threads.cpp
+36-18Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff 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+
121
#include <cstdlib>
222
#include <memory>
323

@@ -6,29 +26,27 @@
626
#define PATH "/plaintext"
727
#define BODY "Hello, World!"
828

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+
}
1734

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+
}
2138

22-
private:
23-
std::shared_ptr<http_response> resp;
39+
private:
40+
std::shared_ptr<httpserver::http_response> resp;
2441
};
2542

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);
3048

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));
3250
hello->with_header("Server", "libhttpserver");
3351

3452
hello_world_resource hwr(hello);
Collapse file

‎examples/custom_access_log.cpp‎

Copy file name to clipboardExpand all lines: examples/custom_access_log.cpp
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,19 @@
2222

2323
#include <httpserver.hpp>
2424

25-
using namespace httpserver;
26-
2725
void custom_access_log(const std::string& url) {
2826
std::cout << "ACCESSING: " << url << std::endl;
2927
}
3028

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+
}
3634
};
3735

38-
int main(int argc, char** argv) {
39-
webserver ws = create_webserver(8080)
36+
int main() {
37+
httpserver::webserver ws = httpserver::create_webserver(8080)
4038
.log_access(custom_access_log);
4139

4240
hello_world_resource hwr;

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.