From 92b2d2a73623147baadd25c41a2bb5a45ca41a88 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Fri, 4 Sep 2020 23:40:37 +0200 Subject: [PATCH] Ignore missingServerName if app failed --- src/App.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/App.h b/src/App.h index 896f0a1..47e2d72 100644 --- a/src/App.h +++ b/src/App.h @@ -53,14 +53,17 @@ public: TemplatedApp &&missingServerName(fu2::unique_function handler) { - httpContext->getSocketContextData()->missingServerNameHandler = std::move(handler); + if (!constructorFailed()) { + httpContext->getSocketContextData()->missingServerNameHandler = std::move(handler); - us_socket_context_on_server_name(SSL, (struct us_socket_context_t *) httpContext, [](struct us_socket_context_t *context, const char *hostname) { + us_socket_context_on_server_name(SSL, (struct us_socket_context_t *) httpContext, [](struct us_socket_context_t *context, const char *hostname) { + + /* This is the only requirements of being friends with HttpContextData */ + HttpContext *httpContext = (HttpContext *) context; + httpContext->getSocketContextData()->missingServerNameHandler(hostname); + }); + } - /* This is the only requirements of being friends with HttpContextData */ - HttpContext *httpContext = (HttpContext *) context; - httpContext->getSocketContextData()->missingServerNameHandler(hostname); - }); return std::move(*this); }