Write Date header in all responses

This commit is contained in:
Alex Hultman
2022-10-16 12:37:21 +02:00
parent 4b80e77c83
commit bcf5034e3c
3 changed files with 38 additions and 2 deletions
+18 -1
View File
@@ -23,11 +23,13 @@
#include <vector>
#include <mutex>
#include <map>
#include <time.h>
#include "PerMessageDeflate.h"
#include "MoveOnlyFunction.h"
struct us_timer_t;
namespace uWS {
struct Loop;
@@ -43,6 +45,10 @@ private:
std::map<void *, MoveOnlyFunction<void(Loop *)>> postHandlers, preHandlers;
public:
LoopData() {
updateDate();
}
~LoopData() {
/* If we have had App.ws called with compression we need to clear this */
if (zlibContext) {
@@ -53,6 +59,15 @@ public:
delete [] corkBuffer;
}
void updateDate() {
time_t now = time(0);
struct tm tstruct;
tstruct = *gmtime(&now);
strftime(date, 32, "%a, %d %b %Y %X GMT", &tstruct);
}
char date[32];
/* Be silent */
bool noMark = false;
@@ -68,6 +83,8 @@ public:
ZlibContext *zlibContext = nullptr;
InflationStream *inflationStream = nullptr;
DeflationStream *deflationStream = nullptr;
us_timer_t *dateTimer;
};
}