;
86 stringfmt = request.
GetEntry(
"fmt", &is_found);
87 if(fmt.empty() || !is_found)
90 stringfilename(request.
GetEntry(
"filename", &is_found));
91 if(is_found && !filename.empty()) {
92 stringis_inline(request.
GetEntry(
"inline", &is_found));
96 "inline; filename=":
"attachment; filename=") +
111 string key= request.
GetEntry(
"key", &is_found);
112 if(
key.empty() || !is_found) {
120 size_ttotal_bytes_written = 0;
122 while(!netstorage_object.
Eof()) {
125 if(!bytes_read)
continue;
128reply.
out().write(
buffer, bytes_read);
129total_bytes_written += bytes_read;
132netstorage_object.
Close();
135 LOG_POST(
Info<<
"retrieved data: "<< total_bytes_written <<
" bytes");
145 if(
autoarg_exception =
dynamic_cast<CArgException*
>(&e)) {
146status_str =
"400 Bad Request";
147message = arg_exception->GetMsg();
150 switch(nc_exception->GetErrCode()) {
152status_str =
"403 Forbidden";
153message = nc_exception->GetMsg();
157status_str =
"404 Not Found";
158message = nc_exception->GetMsg();
174os <<
"Status: "<< status_str <<
HTTP_EOL<<
181 ERR_POST(
"CNetCacheBlobFetchApp::OnException() " 182 "failed to send error page back to the client");
186 catch(exception& ex) {
193 int main(
intargc,
const char* argv[])
201 returnapp.
AppMain(argc, argv);
Exception classes used by the NCBI CGI framework.
Pool of recycled CCompoundID objects.
NetCache BLOB/image fetch application.
virtual int OnException(std::exception &e, CNcbiOstream &os)
This method is called if an exception is thrown during the processing of HTTP request.
string x_GetInitString(const string &key)
virtual int ProcessRequest(CCgiContext &ctx)
This is the method you should override.
Exception class for use by CNetStorage, CNetStorageByKey, and CNetStorageObject.
Basic network-based data object I/O.
Abstract reader-writer interface classes.
#define GRID_APP_CHECK_VERSION_ARGS()
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
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.
virtual int OnException(std::exception &e, CNcbiOstream &os)
This method is called if an exception is thrown during the processing of HTTP request.
void SetHTTPStatus(unsigned int status, const string &reason=kEmptyStr)
Set HTTP status code in the current request context and in the current CHttpResponse if one exists.
void SetHeaderValue(const string &name, const string &value)
CNcbiOstream & out(void) const
Get output stream. Throw exception if GetOutput() is NULL.
void SetContentType(const string &type)
Set content type (text/html by default if not provided)
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.
CDiagContext & GetDiagContext(void)
Get diag context instance.
void SetSplitLogFile(bool value=true)
Split log files flag.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
static void SetOldPostFormat(bool value)
Set old/new format flag.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_REPORT_EXCEPTION(title, ex)
Generate a report on the exception.
void Info(CExceptionArgs_Base &args)
bool Eof(void)
Check if the last Read() has hit EOF.
size_t Read(void *buffer, size_t buf_size)
Read no more than 'buf_size' bytes of the object contents (starting at the current position)
void Close(void)
Finalize and close the current object stream.
CNetStorageObject Open(const string &object_loc)
Open an existing NetStorage object for reading.
@ eNotExists
Illegal op applied to non-existent object.
@ eAuthError
Authentication error (e.g. no FileTrack API key)
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static bool StringToBool(const CTempString str)
Convert string to bool.
static string HtmlEncode(const CTempString str, THtmlEncode flags=fHtmlEnc_EncodeAll)
Encode a string for HTML.
const struct ncbi::grid::netcache::search::fields::KEY key
Defines command line argument related classes.
void s_WriteHeader(const CCgiRequest &request, CCgiResponse &reply)
#define NETSTORAGE_IO_BUFFER_SIZE
int main(int argc, const char *argv[])
NetCache API exception declarations.
Reader-writer based streams.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4