50 while (curr < buf.
Length() - 2) {
56 if (buf.
Index(name, curr) != curr) {
61 if ((value == 0) && doing_set) {
63 buf.
Remove(curr, next - curr + 2);
68 while ((curr < next) && (buf[curr] !=
':'))
71 while ((curr < next) && (buf[curr] ==
' '))
75 return buf(curr, next - curr);
76 buf.
Remove(curr, next - curr);
95 while (curr < buf.
Length() - 2) {
103 Int_t separ = curr + 1;
104 while ((separ < next) && (buf[separ] !=
':'))
106 return buf(curr, separ - curr);
221 if (data && length) {
222 std::copy((
const char *)data, (
const char *)data + length,
fPostData.begin());
223 if (!make_copy)
free(data);
262 std::size_t start_pos = 0;
263 while((start_pos =
fContent.find(from, start_pos)) != std::string::npos) {
264 fContent.replace(start_pos, from.length(), to);
265 start_pos += to.length();
276 void THttpCallArg::SetBinData(
void *
data,
Long_t length)
284 std::copy((
const char *)
data, (
const char *)data + length,
fContent.begin());
304 const char *rslash = strrchr(fullpath,
'/');
308 while ((fullpath != rslash) && (*fullpath ==
'/'))
322 if ((name == 0) || (*name == 0))
325 if (strcmp(name,
"Content-Type") == 0)
327 if (strcmp(name,
"Content-Length") == 0)
340 if ((name == 0) || (*name == 0) || (strcmp(name,
"Content-Length") == 0))
343 if (strcmp(name,
"Content-Type") == 0)
353 std::string THttpCallArg::FillHttpHeader(
const char *
name)
355 std::string hdr(name ? name :
"HTTP/1.1");
358 hdr.append(
" 404 Not Found\r\n" 359 "Content-Length: 0\r\n" 360 "Connection: close\r\n\r\n");
362 hdr.append(
Form(
" 200 OK\r\n" 363 "Content-Type: %s\r\n" 364 "Connection: keep-alive\r\n" 365 "Content-Length: %ld\r\n" 367 GetContentType(), GetContentLength(),
fHeader.
Data()));
377 void THttpCallArg::FillHttpHeader(
TString &hdr,
const char *
name)
379 hdr = FillHttpHeader(name).c_str();
387 char *objbuf = (
char *)GetContent();
388 Long_t objlen = GetContentLength();
390 unsigned long objcrc = R__crc32(0, NULL, 0);
391 objcrc = R__crc32(objcrc, (
const unsigned char *)objbuf, objlen);
394 Int_t buflen = 10 + objlen + 8;
399 buffer.resize(buflen);
401 char *bufcur = (
char *)buffer.data();
417 memcpy(dummy, bufcur - 6, 6);
420 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, objbuf, objlen);
422 memcpy(bufcur - 6, dummy, 6);
424 bufcur += (ziplen - 6);
427 *bufcur++ = objcrc & 0xff;
428 *bufcur++ = (objcrc >> 8) & 0xff;
429 *bufcur++ = (objcrc >> 16) & 0xff;
430 *bufcur++ = (objcrc >> 24) & 0xff;
433 *bufcur++ = objlen & 0xff;
434 *bufcur++ = (objlen >> 8) & 0xff;
435 *bufcur++ = (objlen >> 16) & 0xff;
436 *bufcur++ = (objlen >> 24) & 0xff;
438 buffer.resize(bufcur - (
char *)buffer.data());
451 void THttpCallArg::NotifyCondition()
464 void THttpCallArg::HttpReplied()
void SetTextContent(std::string &&txt)
Set content type as "text/plain" and also assigns content After method call argument.
void SetBinary()
Set content type as "application/x-binary".
void ReplaceAllinContent(const std::string &from, const std::string &to)
Replace all occurrences of.
std::string fPostData
!< content - text or binary
TString AccessHeader(TString &buf, const char *name, const char *value=nullptr, Bool_t doing_set=kFALSE)
method used to get or set http header in the string buffer Header has following format: field1 : valu...
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
TString & Insert(Ssiz_t pos, const char *s)
void SetContentType(const char *typ)
set content type like "text/xml" or "application/json"
TString CountHeader(const TString &buf, Int_t number=-1111) const
method used to counter number of headers or returns name of specified header
void SetContent(const char *cont)
Set content as text.
void SetPostData(void *data, Long_t length, Bool_t make_copy=kFALSE)
void SetEncoding(const char *typ)
Set Content-Encoding header like gzip.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
void SetPathAndFileName(const char *fullpath)
set complete path of requested http element For instance, it could be "/folder/subfolder/get.bin" Here "/folder/subfolder/" is element path and "get.bin" requested file.
TString fContentType
! type of content
std::shared_ptr< THttpWSEngine > fWSEngine
! web-socket engine, which supplied to run created web socket
void Clear()
Clear string without changing its capacity.
void SetBinaryContent(std::string &&bin)
Set content type as "application/x-binary" and also assigns content After method call argument...
TString fPathName
! item path
TString & Append(const char *cs)
void AssignWSId()
Assign websocket identifier from the engine.
void SetJson()
Set content type as "application/json".
Bool_t fNotifyFlag
! indicate that notification called
void SetXmlContent(std::string &&xml)
Set content type as "text/xml" and also assigns content After method call argument.
char * Form(const char *fmt,...)
void SetText()
Set content type as "text/plain".
TString & Remove(Ssiz_t pos)
std::condition_variable fCond
! condition used to wait for processing
void SetWSId(UInt_t id)
set web-socket id
void SetXml()
Set content type as "text/xml".
TString fHeader
! response header like ContentEncoding, Cache-Control and so on
static RooMathCoreReg dummy
void SetJsonContent(std::string &&json)
Set content type as "application/json" and also assigns content After method call argument...
void AddHeader(const char *name, const char *value)
Set name: value pair to reply header Content-Type field handled separately - one should use SetConten...
basic_json<> json
default JSON class
virtual ~THttpCallArg()
destructor
TString fFileName
! file name
std::shared_ptr< THttpWSEngine > TakeWSEngine()
takeout websocket handle with HTTP call can be done only once
Bool_t CompressWithGzip()
compress reply data with gzip compression
TString GetHeader(const char *name)
return specified header
const char * Data() const