37 const char *
GetWSKind()
const override {
return "longpoll"; }
49#ifndef HTTP_WITHOUT_FASTCGI
61 "Status: 404 Not Found\r\n"
62 "Content-Length: 0\r\n"
63 "Connection: close\r\n\r\n");
68 "Content-Type: %s\r\n"
69 "Content-Length: %d\r\n"
73 FCGX_PutStr(buf.c_str(), buf.length(), request->out);
89 auto arg = std::make_shared<TFastCgiCallArg>(
can_postpone);
106 arg->SetPostData(std::move(buf));
110 for (
char **
envp = request->envp; *
envp !=
nullptr;
envp++) {
120 arg->SetRequestHeader(header);
122 TString username = arg->GetRequestHeader(
"REMOTE_USER");
123 if ((username.
Length() > 0) && (arg->GetRequestHeader(
"AUTH_TYPE").Length() > 0))
124 arg->SetUserName(username);
128 "Content-type: text/html\r\n"
130 "<title>FastCGI echo</title>"
131 "<h1>FastCGI echo</h1>\n");
133 FCGX_FPrintF(request->out,
"Request %d:<br/>\n<pre>\n", count);
134 FCGX_FPrintF(request->out,
" Method : %s\n", arg->GetMethod());
135 FCGX_FPrintF(request->out,
" PathName : %s\n", arg->GetPathName());
136 FCGX_FPrintF(request->out,
" FileName : %s\n", arg->GetFileName());
137 FCGX_FPrintF(request->out,
" Query : %s\n", arg->GetQuery());
138 FCGX_FPrintF(request->out,
" PostData : %ld\n", arg->GetPostDataLength());
141 FCGX_FPrintF(request->out,
"Environment:<br/>\n<pre>\n");
142 for (
char **
envp = request->envp; *
envp !=
nullptr;
envp++)
157 std::string
hdr = arg->FillHttpHeader(
"Status:");
159 }
else if (arg->IsFile()) {
165 arg->CompressWithGzip();
167 std::string
hdr = arg->FillHttpHeader(
"Status:");
170 FCGX_PutStr((
const char *)arg->GetContent(), (
int)arg->GetContentLength(), request->out);
176 std::condition_variable
cond;
178 std::unique_ptr<FCGX_Request> arg;
185 std::unique_ptr<FCGX_Request> request;
190 std::unique_lock<std::mutex>
lk(
m);
195 std::swap(arg, request);
208 std::vector<std::thread>
workers;
213 auto request = std::make_unique<FCGX_Request>();
223 std::lock_guard<std::mutex>
lk(
m);
225 std::swap(request, arg);
315 :
THttpEngine(
"fastcgi",
"fastcgi interface to webserver")
345#ifndef HTTP_WITHOUT_FASTCGI
351 if ((args != 0) && (
strlen(args) > 0)) {
355 while ((*args != 0) && (*args >=
'0') && (*args <=
'9'))
356 sport.Append(*args++);
359 while ((*args != 0) && (*args !=
'?'))
369 if (
url.GetValueFromOptions(
"debug") != 0)
372 if (
url.HasOption(
"thrds"))
373 nthrds =
url.GetIntValueFromOptions(
"thrds");
375 const char *top =
url.GetValueFromOptions(
"top");
382 Info(
"Create",
"Starting FastCGI server on port %s",
sport.Data() + 1);
395 Error(
"Create",
"ROOT compiled without fastcgi support");
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void process_request(TFastCgi *engine, FCGX_Request *request, bool can_postpone)
void run_single_thread(TFastCgi *engine)
void run_multi_threads(TFastCgi *engine, Int_t nthrds)
void FCGX_ROOT_send_file(FCGX_Request *request, const char *fname)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
const char * GetWSPlatform() const override
provide WS platform
const char * GetWSKind() const override
provide WS kind
Bool_t CanPostpone() const override
All FastCGI requests should be immediately replied to get slot for next.
TFastCgiCallArg(bool can_postpone)
THttpEngine implementation, based on fastcgi package.
TFastCgi()
normal constructor
Bool_t IsTerminating() const
TString fTopName
! name of top item
std::unique_ptr< std::thread > fThrd
! thread which takes requests, can be many later
Bool_t fDebugMode
! debug mode, may required for fastcgi debugging in other servers
const char * GetTopName() const
virtual ~TFastCgi()
destructor
Bool_t Create(const char *args) override
create engine data
Int_t fSocket
! socket used by fastcgi
Bool_t IsDebugMode() const
Bool_t fTerminating
! set when http server wants to terminate all engines
Contains arguments for single HTTP call.
Abstract class for implementing http protocol for THttpServer.
THttpServer * GetServer() const
Returns pointer to THttpServer associated with engine.
Bool_t IsFileRequested(const char *uri, TString &res) const
Check if file is requested, thread safe.
Bool_t ExecuteHttp(std::shared_ptr< THttpCallArg > arg)
Execute HTTP request.
static char * ReadFileContent(const char *filename, Int_t &len)
Reads content of file from the disk.
static const char * GetMimeType(const char *path)
Guess mime type base on file extension.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
This class represents a WWW compatible URL.