56 void Init(
void)
override;
112 arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
113 "FastCGI MT sample application");
115 arg_desc->AddOptionalKey(
"message",
117 "Message passed to CGI application",
121 arg_desc->AddDefaultKey(
"delay",
123 "Delay before sending reply, seconds",
137 int delay =
GetArgs()[
"delay"].AsInteger();
154 bool is_message =
false;
155 string message = request.
GetEntry(
"Message", &is_message);
157 message =
"'" + message +
"'";
169 unique_ptr<CHTMLPage> page;
172 string html_path =
"cgi_sample.html";
173 if ( !
CFile(html_path).Exists() ) {
176 page.reset(
new CHTMLPage(
"Sample CGI", html_path));
177 }
catch (exception& e) {
178 ERR_POST(
"Failed to create Sample CGI HTML page: " << e.what());
187 page->AddTagMap(
"MESSAGE",
text);
190 page->AddTagMap(
"SELF_URL", self_url);
192 catch (exception& e) {
193 ERR_POST(
"Failed to populate Sample CGI HTML page: " << e.what());
199 _TRACE(
"stream status: " <<
ctx.GetStreamStatus());
206 }
catch (exception& e) {
207 ERR_POST(
"Failed to compose/send Sample CGI HTML page: " << e.what());
224 if ( args[
"message"] ) {
226 const string& m = args[
"message"].AsString();
230 const auto& values = args[
"message"].GetStringList();
232 for (
const auto& v : values) {
Base class for request processors.
CCgiRequestProcessor * CreateRequestProcessor(void) override
Create request processor to process the request.
void Init(void) override
This method is called on the CGI application initialization – before starting to process a HTTP reque...
CFastCgiMTSampleRequestProcessor(CFastCgiMTSampleApplication &app)
~CFastCgiMTSampleRequestProcessor(void) override
int ProcessRequest(CCgiContext &context) override
Process request provided by the context. By default calls application's ProcessRequest.
int NcbiSys_main(int argc, ncbi::TXChar *argv[])
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ fAllowMultiple
Repeated key arguments are legal (use with AddKey)
@ eString
An arbitrary string.
@ eInteger
Convertible into an integer number (int or Int8)
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
virtual void Init(void)
This method is called on the CGI application initialization – before starting to process a HTTP reque...
void SetRequestFlags(int flags)
Set cgi parsing flag.
CCgiApplication & GetApp(void)
CNcbiOstream & out(void) const
Get output stream. Throw exception if GetOutput() is NULL.
CNcbiOstream & WriteHeader(void) const
Write HTTP response header to the output stream.
const CCgiEntry & GetEntry(const string &name, bool *is_found=0) const
Get entry value by name.
ERequestMethod GetRequestMethod(void) const
Get request method.
@ fCaseInsensitiveArgs
use case insensitive CGI arguments
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
static void text(MDB_val *v)
void SleepSec(unsigned long sec, EInterruptOnSignal onsignal=eRestartOnSignal)
Sleep.