44 const void *ptr = (
const void *)
this;
55 fPoll->NotifyCondition();
70 std::copy((
const char *)buf, (
const char *)buf + len, res.begin());
74 int hdrlen = hdr ? strlen(hdr) : 0;
75 std::string hdrstr =
"bin:";
76 hdrstr.append(std::to_string(hdrlen));
78 while ((hdrstr.length() + 1 + hdrlen) % 8 != 0)
84 res.resize(hdrstr.length() + len);
85 std::copy(hdrstr.begin(), hdrstr.begin() + hdrstr.length(), res.begin());
86 std::copy((
const char *)buf, (
const char *)buf + len, res.begin() + hdrstr.length());
99 fPoll->SetBinaryContent(std::move(buf2));
100 fPoll->NotifyCondition();
103 fQueue.emplace(
true, std::move(buf2));
105 Error(
"Send",
"Too many send operations %u in the queue, check algorithms", (
unsigned)
fQueue.size());
117 fPoll->SetBinaryContent(std::move(buf2));
119 fPoll->SetExtraHeader(
"LongpollHeader", hdr);
120 fPoll->NotifyCondition();
123 fQueue.emplace(
true, std::move(buf2), hdr);
125 Error(
"SendHeader",
"Too many send operations %u in the queue, check algorithms", (
unsigned)
fQueue.size());
135 std::string sendbuf(
fRaw ?
"txt:" :
"");
139 if (
fRaw)
fPoll->SetBinaryContent(std::move(sendbuf));
140 else fPoll->SetTextContent(std::move(sendbuf));
141 fPoll->NotifyCondition();
144 fQueue.emplace(
false, std::move(sendbuf));
146 Error(
"SendCharStar",
"Too many send operations %u in the queue, check algorithms", (
unsigned)
fQueue.size());
157 if (!strstr(arg->GetQuery(),
"&dummy")) {
165 Fatal(
"PreviewData",
"Submit same THttpCallArg object once again");
168 Error(
"PreviewData",
"Get next dummy request when previous not completed");
172 fPoll->NotifyCondition();
179 arg->SetBinaryContent(std::move(item.
fData));
181 arg->SetExtraHeader(
"LongpollHeader", item.
fHdr.c_str());
183 arg->SetTextContent(std::move(item.
fData));
203 (
gLongPollNope.compare((
const char *)arg->GetContent()) != 0))
209 arg->SetBinaryContent(std::move(item.
fData));
211 arg->SetExtraHeader(
"LongpollHeader", item.
fHdr.c_str());
213 arg->SetTextContent(std::move(item.
fData));
virtual void PostProcess(std::shared_ptr< THttpCallArg > &arg)
Normally requests from client does not replied directly for longpoll socket Therefore one can use suc...
void Fatal(const char *location, const char *msgfmt,...)
virtual UInt_t GetId() const
returns ID of the engine, created from this pointer
std::string fHdr
! optional header for raw data
virtual void Send(const void *buf, int len)
Send binary data via connection - not supported.
static const std::string gLongPollNope
!< entries submitted to client
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
std::string MakeBuffer(const void *buf, int len, const char *hdr=nullptr)
!< default reply on the longpoll request
std::shared_ptr< THttpCallArg > fPoll
!< if true, only content can be used for data transfer
std::queue< QueueItem > fQueue
!< hold polling request, which can be immediately used for the next sending
void Error(const char *location, const char *msgfmt,...)
virtual void ClearHandle()
clear request, waiting for next portion of data
virtual void SendCharStar(const char *buf)
Send const char data Either do it immediately or keep in internal buffer.
THttpLongPollEngine(bool raw=false)
constructor
virtual void SendHeader(const char *hdr, const void *buf, int len)
Send binary data with text header via connection - not supported.
virtual Bool_t PreviewData(std::shared_ptr< THttpCallArg > &arg)
Preview data for given socket function called in the user code before processing correspondent websoc...
std::string fData
! text or binary data
bool fBinary
! is binary data