43 const void *ptr = (
const void *)
this;
54 std::shared_ptr<THttpCallArg> poll;
57 std::lock_guard<std::mutex> grd(
fMutex);
58 poll = std::move(
fPoll);
63 poll->NotifyCondition();
78 std::copy((
const char *)buf, (
const char *)buf + len, res.begin());
82 int hdrlen = hdr ? strlen(hdr) : 0;
83 std::string hdrstr =
"bin:";
84 hdrstr.append(std::to_string(hdrlen));
86 while ((hdrstr.length() + 1 + hdrlen) % 8 != 0)
92 res.resize(hdrstr.length() + len);
93 std::copy(hdrstr.begin(), hdrstr.begin() + hdrstr.length(), res.begin());
94 std::copy((
const char *)buf, (
const char *)buf + len, res.begin() + hdrstr.length());
104 std::shared_ptr<THttpCallArg> poll;
109 std::lock_guard<std::mutex> grd(
fMutex);
111 poll = std::move(
fPoll);
114 std::swap(
fBuf, sendbuf);
120 Error(
"Send",
"Operation invoked before polling request obtained");
124 poll->SetBinaryContent(std::move(sendbuf));
125 poll->NotifyCondition();
133 std::shared_ptr<THttpCallArg> poll;
135 std::string sendbuf =
MakeBuffer(buf, len, hdr);
138 std::lock_guard<std::mutex> grd(
fMutex);
140 poll = std::move(
fPoll);
144 std::swap(
fBuf, sendbuf);
150 Error(
"SendHeader",
"Operation invoked before polling request obtained");
154 poll->SetBinaryContent(std::move(sendbuf));
156 poll->SetExtraHeader(
"LongpollHeader", hdr);
157 poll->NotifyCondition();
167 std::shared_ptr<THttpCallArg> poll;
169 std::string sendbuf(
fRaw ?
"txt:" :
"");
173 std::lock_guard<std::mutex> grd(
fMutex);
175 poll = std::move(
fPoll);
178 std::swap(
fBuf, sendbuf);
184 Error(
"SendCharStart",
"Operation invoked before polling request obtained");
188 if (
fRaw) poll->SetBinaryContent(std::move(sendbuf));
189 else poll->SetTextContent(std::move(sendbuf));
190 poll->NotifyCondition();
201 if (!strstr(arg->GetQuery(),
"&dummy"))
204 std::shared_ptr<THttpCallArg> poll;
207 if (arg->CanPostpone()) {
208 std::lock_guard<std::mutex> grd(
fMutex);
214 poll = std::move(
fPoll);
225 poll->NotifyCondition();
241 std::string sendbuf, sendhdr;
244 std::lock_guard<std::mutex> grd(
fMutex);
248 std::swap(sendbuf,
fBuf);
254 arg->SetTextContent(std::move(sendbuf));
256 arg->SetBinaryContent(std::move(sendbuf));
257 if (!sendhdr.empty())
258 arg->SetExtraHeader(
"LongpollHeader", sendhdr.c_str());
271 std::lock_guard<std::mutex> grd(
fMutex);
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
std::string fBufHeader
!< buffered data
std::string MakeBuffer(const void *buf, int len, const char *hdr=nullptr)
!< default reply on the longpoll request
std::shared_ptr< THttpCallArg > fPoll
!< protect polling request to use it from different threads
void Send(const void *buf, int len) override
Send binary data via connection.
void SendHeader(const char *hdr, const void *buf, int len) override
Send binary data with text header via connection.
std::mutex fMutex
!< if true, only content can be used for data transfer
virtual Bool_t CanSendDirectly() override
Indicate that polling requests is there or buffer empty and can be immediately invoked.
THttpLongPollEngine(bool raw=false)
constructor
static const std::string gLongPollNope
!< buffered header
void ClearHandle(Bool_t) override
Clear request.
void SendCharStar(const char *buf) override
Send const char data.
Bool_t PreProcess(std::shared_ptr< THttpCallArg > &arg) override
Preview data for given socket.
EBufKind fBufKind
!< hold polling request, which can be immediately used for the next sending
UInt_t GetId() const override
Returns ID of the engine, created from this pointer.
void PostProcess(std::shared_ptr< THttpCallArg > &arg) override
Post process http request.
std::string fBuf
!< if buffered data available
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.