From d683b750f4ccb775075fdab802d7a1f56531d2d4 Mon Sep 17 00:00:00 2001
From: Sergey Linev <S.Linev@gsi.de>
Date: Tue, 18 Apr 2017 14:23:12 +0200
Subject: [PATCH] http: let postpone execution of http request

THttpServer may decide to postpone reply on the requests.
Such reply can be performed later via invoking some user code.
Will be used for implementing long poll
---
 net/http/inc/THttpCallArg.h   |  6 ++++++
 net/http/src/THttpCallArg.cxx | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/net/http/inc/THttpCallArg.h b/net/http/inc/THttpCallArg.h
index df13f5d37cd..0c7ed7e1add 100644
--- a/net/http/inc/THttpCallArg.h
+++ b/net/http/inc/THttpCallArg.h
@@ -141,6 +141,9 @@ public:
    /** mark reply as 404 error - page/request not exists or refused */
    void Set404() { SetContentType("_404_"); }
 
+   /** mark reply as 404 error - page/request not exists or refused */
+   void SetPostponed() { SetContentType("_postponed_"); }
+
    /** indicate that http request should response with file content */
    void SetFile(const char *filename = 0)
    {
@@ -193,6 +196,7 @@ public:
    Bool_t IsContentType(const char *typ) const { return fContentType == typ; }
    Bool_t Is404() const { return IsContentType("_404_"); }
    Bool_t IsFile() const { return IsContentType("_file_"); }
+   Bool_t IsPostponed() const { return IsContentType("_postponed_"); }
    const char *GetContentType() const { return fContentType.Data(); }
 
    void SetBinData(void *data, Long_t length);
@@ -201,6 +205,8 @@ public:
 
    const void *GetContent() const { return IsBinData() ? fBinData : fContent.Data(); }
 
+   void NotifyCondition();
+
    ClassDef(THttpCallArg, 0) // Arguments for single HTTP call
 };
 
diff --git a/net/http/src/THttpCallArg.cxx b/net/http/src/THttpCallArg.cxx
index b7927d2c4b0..f3b93de87b6 100644
--- a/net/http/src/THttpCallArg.cxx
+++ b/net/http/src/THttpCallArg.cxx
@@ -312,3 +312,13 @@ Bool_t THttpCallArg::CompressWithGzip()
 
    return kTRUE;
 }
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// method used to notify condition which waiting when operation will complete
+/// Condition notified only if not-postponed state is set
+
+void THttpCallArg::NotifyCondition()
+{
+   if (!IsPostponed()) fCond.notify_one();
+}
-- 
GitLab