diff --git a/Makefile b/Makefile index 7c94cc0..fd10f29 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded -override CXXFLAGS += -lpthread -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -std=c++17 -Isrc -IuSockets/src +override CXXFLAGS += -lpthread -Wextra -Wno-unused-parameter -std=c++17 -Isrc -IuSockets/src override LDFLAGS += uSockets/*.o -lz DESTDIR ?= diff --git a/src/HttpRouter.h b/src/HttpRouter.h index c8de7c8..b8839f5 100644 --- a/src/HttpRouter.h +++ b/src/HttpRouter.h @@ -61,6 +61,8 @@ private: std::vector> children; std::vector handlers; bool isHighPriority; + + Node(std::string name) : name(name) {} } root = {"rootNode"}; /* Advance from parent to child, adding child if necessary */ @@ -72,7 +74,7 @@ private: } /* Insert sorted, but keep order if parent is root (we sort methods by priority elsewhere) */ - std::unique_ptr newNode(new Node({child})); + std::unique_ptr newNode(new Node(child)); newNode->isHighPriority = isHighPriority; return parent->children.emplace(std::upper_bound(parent->children.begin(), parent->children.end(), newNode, [parent, this](auto &a, auto &b) { diff --git a/src/WebSocketProtocol.h b/src/WebSocketProtocol.h index 34ec31b..f3a56c9 100644 --- a/src/WebSocketProtocol.h +++ b/src/WebSocketProtocol.h @@ -160,14 +160,14 @@ struct CloseFrame { static inline CloseFrame parseClosePayload(char *src, size_t length) { /* If we get no code or message, default to reporting 1005 no status code present */ - CloseFrame cf = {1005}; + CloseFrame cf = {1005, nullptr, 0}; if (length >= 2) { memcpy(&cf.code, src, 2); cf = {cond_byte_swap(cf.code), src + 2, length - 2}; if (cf.code < 1000 || cf.code > 4999 || (cf.code > 1011 && cf.code < 4000) || (cf.code >= 1004 && cf.code <= 1006) || !isValidUtf8((unsigned char *) cf.message, cf.length)) { /* Even though we got a WebSocket close frame, it in itself is abnormal */ - return {1006}; + return {1006, nullptr, 0}; } } return cf;