diff --git a/examples/UpgradeAsync.cpp b/examples/UpgradeAsync.cpp index 0c5301be4..011e3496d 100644 --- a/examples/UpgradeAsync.cpp +++ b/examples/UpgradeAsync.cpp @@ -77,13 +77,15 @@ int main() { * such as res->writeStatus(...)->writeHeader(...)->end(...); or similar.*/ /* This call will immediately emit .open event */ - upgradeData->httpRes->template upgrade({ - /* We initialize PerSocketData struct here */ - .something = 13 - }, upgradeData->secWebSocketKey, - upgradeData->secWebSocketProtocol, - upgradeData->secWebSocketExtensions, - upgradeData->context); + upgradeData->httpRes->cork([upgradeData]() { + upgradeData->httpRes->template upgrade({ + /* We initialize PerSocketData struct here */ + .something = 13 + }, upgradeData->secWebSocketKey, + upgradeData->secWebSocketProtocol, + upgradeData->secWebSocketExtensions, + upgradeData->context); + }); } else { std::cout << "Async task done, but the HTTP socket was closed. Skipping upgrade to WebSocket!" << std::endl; } diff --git a/src/HttpRouter.h b/src/HttpRouter.h index 12c7fc1d1..34c23229a 100644 --- a/src/HttpRouter.h +++ b/src/HttpRouter.h @@ -134,7 +134,7 @@ struct HttpRouter { inline std::pair getUrlSegment(int urlSegment) { if (urlSegment > urlSegmentTop) { /* Signal as STOP when we have no more URL or stack space */ - if (!currentUrl.length() || urlSegment > MAX_URL_SEGMENTS - 1) { + if (!currentUrl.length() || urlSegment > int(MAX_URL_SEGMENTS - 1)) { return {{}, true}; }