Skip to content

Commit b04b1a7

Browse files
committed
Fixed endless looping when TLS-handshake.
Added http/1.1 as default protocol for non-ALPN tls connections. Fixed many warnings in code. Changed code style.
1 parent 1796b81 commit b04b1a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2803
-1453
lines changed

projects/qt-creator/httpserver.qbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Project {
1212

1313
Properties {
1414
condition: qbs.targetOS.contains("linux")
15-
cpp.platformDefines: outer.concat(["POSIX"])
15+
cpp.defines: outer.concat(["POSIX"])
1616
cpp.dynamicLibraries: outer.concat(["dl", "pthread", "rt"])
1717
}
1818
Properties {
1919
condition: qbs.targetOS.contains("windows")
20-
cpp.platformDefines: outer.concat(["WIN32", "NOMINMAX"])
20+
cpp.defines: outer.concat(["WIN32", "NOMINMAX"])
2121
}
2222

2323
files: [

src/Main.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,23 @@ int main(const int argc, const char *argv[])
1717

1818
int exitcode = EXIT_FAILURE;
1919

20-
if (1 < argc)
21-
{
20+
if (1 < argc) {
2221
auto const command = commands.find(argv[1]);
2322

24-
if (commands.cend() != command)
25-
{
23+
if (commands.cend() != command) {
2624
HttpServer::Server server;
2725

28-
if (bindSignalHandlers(&server) )
29-
{
26+
if (bindSignalHandlers(&server) ) {
3027
exitcode = command->second(&server, argc, argv);
31-
3228
stopSignalHandlers();
3329
}
34-
}
35-
else
36-
{
30+
} else {
3731
std::cout << "Unknown parameter, see --help" << std::endl;
3832
}
3933
}
40-
else if (1 == argc)
41-
{
34+
else if (1 == argc) {
4235
std::cout << "Try to run with the parameter --help" << std::endl;
43-
}
44-
else
45-
{
36+
} else {
4637
std::cout << "The number of arguments cannot be equal to zero. Enter the parameter --help" << std::endl;
4738
}
4839

src/SignalHandlers.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ static void handlerSigUsr2(const int) noexcept {
5656
* It doesn't work in case the program was launched and was
5757
* attempted to finish under different remote sessions.
5858
*/
59-
static ::LRESULT CALLBACK WndProc(const ::HWND hWnd, const ::UINT message, const ::WPARAM wParam, const ::LPARAM lParam) noexcept
60-
{
59+
static ::LRESULT CALLBACK WndProc(
60+
const ::HWND hWnd,
61+
const ::UINT message,
62+
const ::WPARAM wParam,
63+
const ::LPARAM lParam
64+
) noexcept {
6165
switch (message)
6266
{
6367
case SIGTERM: {
@@ -105,9 +109,23 @@ static ::LRESULT CALLBACK WndProc(const ::HWND hWnd, const ::UINT message, const
105109
return 0;
106110
}
107111

108-
static ::WPARAM mainMessageLoop(const ::HINSTANCE hInstance, Utils::Event * const eventWindowCreation) noexcept
109-
{
110-
const ::HWND hWnd = ::CreateWindow(myWndClassName, nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, nullptr, nullptr, hInstance, nullptr);
112+
static ::WPARAM mainMessageLoop(
113+
const ::HINSTANCE hInstance,
114+
Utils::Event * const eventWindowCreation
115+
) noexcept {
116+
const ::HWND hWnd = ::CreateWindow(
117+
myWndClassName,
118+
nullptr,
119+
0,
120+
CW_USEDEFAULT,
121+
CW_USEDEFAULT,
122+
0,
123+
0,
124+
nullptr,
125+
nullptr,
126+
hInstance,
127+
nullptr
128+
);
111129

112130
eventWindowCreation->notify(); // After this action, eventWindowCreation will be destroyed (in the other thread)
113131

@@ -207,7 +225,7 @@ bool bindSignalHandlers(HttpServer::Server *server) noexcept
207225
::signal(SIGPIPE, SIG_IGN);
208226

209227
#else
210-
#error "Undefine platform"
228+
#error "Undefined platform"
211229
#endif
212230

213231
return true;

src/server/Request.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ namespace HttpServer
1717

1818
// timeout = std::chrono::milliseconds::zero();
1919
}
20-
};
20+
}

src/server/Request.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
namespace HttpServer
1010
{
11-
enum ConnectionParams
12-
{
11+
enum ConnectionParams {
1312
CONNECTION_CLOSE = 0,
1413
CONNECTION_REUSE = 1,
1514
CONNECTION_LEAVE_OPEN = 2
@@ -36,9 +35,8 @@ namespace HttpServer
3635
void clear() noexcept;
3736
};
3837

39-
struct DataTransfer
40-
{
38+
struct DataTransfer {
4139
size_t full_size;
4240
size_t send_total;
4341
};
44-
};
42+
}

0 commit comments

Comments
 (0)