From 270308f10446c55b4a8c3c6ada62f81e77e1917c Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Fri, 18 Sep 2020 23:42:21 +0200 Subject: [PATCH] Add Loop::setSilent --- src/HttpResponse.h | 7 +++++-- src/Loop.h | 5 +++++ src/LoopData.h | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/HttpResponse.h b/src/HttpResponse.h index 954b5a4..436e6e3 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -82,9 +82,12 @@ private: /* Called only once per request */ void writeMark() { + /* You can disable this altogether */ #ifndef UWS_HTTPRESPONSE_NO_WRITEMARK - /* We only expose major version */ - writeHeader("uWebSockets", "18"); + if (!Super::getLoopData()->noMark) { + /* We only expose major version */ + writeHeader("uWebSockets", "18"); + } #endif } diff --git a/src/Loop.h b/src/Loop.h index 6d5137c..62b276a 100644 --- a/src/Loop.h +++ b/src/Loop.h @@ -164,6 +164,11 @@ public: void integrate() { us_loop_integrate((us_loop_t *) this); } + + /* Dynamically change this */ + void setSilent(bool silent) { + ((LoopData *) us_loop_ext((us_loop_t *) this))->noMark = silent; + } }; /* Can be called from any thread to run the thread local loop */ diff --git a/src/LoopData.h b/src/LoopData.h index ffcd7cf..eba52e2 100644 --- a/src/LoopData.h +++ b/src/LoopData.h @@ -53,6 +53,9 @@ public: delete [] corkBuffer; } + /* Be silent */ + bool noMark = false; + /* Good 16k for SSL perf. */ static const int CORK_BUFFER_SIZE = 16 * 1024;