12 #ifndef ROOT_THttpCallArg 13 #define ROOT_THttpCallArg 19 #include <condition_variable> 81 void SetMethod(
const char *method) { fMethod = method; }
84 void SetTopName(
const char *topname) { fTopName = topname; }
142 {
return TString(fPostData.c_str()); }
187 void AddHeader(
const char *name,
const char *value);
212 std::string FillHttpHeader(
const char *header =
nullptr);
216 Bool_t IsContentType(
const char *typ)
const {
return fContentType == typ; }
217 const char *GetContentType()
const {
return fContentType.
Data(); }
219 Bool_t Is404()
const {
return IsContentType(
"_404_"); }
220 Bool_t IsFile()
const {
return IsContentType(
"_file_"); }
221 Bool_t IsPostponed()
const {
return IsContentType(
"_postponed_"); }
222 Bool_t IsText()
const {
return IsContentType(
"text/plain"); }
223 Bool_t IsXml()
const {
return IsContentType(
"text/xml"); }
224 Bool_t IsJson()
const {
return IsContentType(
"application/json"); }
225 Bool_t IsBinary()
const {
return IsContentType(
"application/x-binary"); }
229 Long_t GetContentLength()
const {
return (
Long_t) fContent.length(); }
230 const void *GetContent()
const {
return fContent.data(); }
232 void NotifyCondition();
234 virtual void HttpReplied();
236 template <
class T,
typename... Args>
237 void CreateWSEngine(Args... args)
239 fWSEngine = std::make_shared<T>(args...);
const char * GetFileName() const
returns file name from request URL
void SetTextContent(std::string &&txt)
Set content type as "text/plain" and also assigns content After method call argument.
void SetRequestHeader(const char *h)
set full set of request header
Bool_t IsMethod(const char *name) const
returns kTRUE if post method is used
UInt_t fWSId
! websocket identifier, used in web-socket related operations
Bool_t IsPostMethod() const
returns kTRUE if post method is used
void SetPathName(const char *p)
set request path name
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
UInt_t GetWSId() const
get web-socket id
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...
Int_t NumHeader() const
returns number of fields in header
TString fQuery
! additional arguments
const char * GetPathName() const
returns path name from request URL
void SetQuery(const char *q)
set request query
void SetFile(const char *filename=nullptr)
indicate that http request should response with file content
const char * GetQuery() const
returns request query (string after ? in request URL)
void SetContentType(const char *typ)
set content type like "text/xml" or "application/json"
void SetPostponed()
mark as postponed - reply will not be send to client immediately
void SetUserName(const char *n)
set name of authenticated user
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 SetTopName(const char *topname)
set engine-specific top-name
#define ClassDef(name, id)
void SetEncoding(const char *typ)
Set Content-Encoding header like gzip.
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 SetBinaryContent(std::string &&bin)
Set content type as "application/x-binary" and also assigns content After method call argument...
TString fPathName
! item path
#define _R__DEPRECATED_618(REASON)
void Set404()
mark reply as 404 error - page/request not exists or refused
Int_t NumRequestHeader() const
returns number of fields in request header
const char * GetUserName() const
return authenticated user name (0 - when no authentication)
TString fRequestHeader
! complete header, provided with request
TString GetPostDataAsString() const _R__DEPRECATED_618("Use other methods to access POST data")
returns post data as TString
void AssignWSId()
Assign websocket identifier from the engine.
TString fTopName
! top item name
void SetJson()
Set content type as "application/json".
Bool_t fNotifyFlag
! indicate that notification called
void SetExtraHeader(const char *name, const char *value)
add extra http header value to the reply
const void * GetPostData() const
return pointer on posted with request data
void SetXmlContent(std::string &&xml)
Set content type as "text/xml" and also assigns content After method call argument.
const char * GetTopName() const
returns engine-specific top-name
void SetText()
Set content type as "text/plain".
void SetFileName(const char *f)
set request file name
TString fUserName
! authenticated user name (if any)
std::condition_variable fCond
! condition used to wait for processing
Int_t fZipping
! indicate if and when content should be compressed
void SetWSId(UInt_t id)
set web-socket id
void SetMethod(const char *method)
set request method kind like GET or POST
void SetXml()
Set content type as "text/xml".
TString fHeader
! response header like ContentEncoding, Cache-Control and so on
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Mother of all ROOT objects.
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...
TString fMethod
! request method like GET or POST
basic_json<> json
default JSON class
Int_t Atoi() const
Return integer value of string.
void SetZipping(Int_t mode=kZipLarge)
TString GetRequestHeaderName(Int_t number) const
returns field name in request header
TString GetRequestHeader(const char *name)
get named field from request header
Long_t GetPostDataLength() const
return length of posted with request data
virtual ~THttpCallArg()
destructor
std::shared_ptr< THttpWSEngine > TakeWSEngine()
takeout websocket handle with HTTP call can be done only once
TString fFileName
! file name
const char * GetMethod() const
returns request method like GET or POST
Bool_t CompressWithGzip()
compress reply data with gzip compression
TString GetHeader(const char *name)
return specified header
TString GetHeaderName(Int_t number) const
returns field name in header
const char * Data() const