NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
CCgiResponse Class Reference

Search Toolkit Book for CCgiResponse

#include <cgi/ncbicgir.hpp>

+ Collaboration diagram for CCgiResponse:

Public Types

enum  EMultipartMode { eMultipart_none , eMultipart_mixed , eMultipart_related , eMultipart_replace }
 

Public Member Functions

 CCgiResponse (CNcbiOstream *os=NULL, int ofd=-1)
 
 ~CCgiResponse (void)
 
void SetRawCgi (bool is_raw)
 
bool IsRawCgi (void) const
 
void SetStatus (unsigned int code, const string &reason=kEmptyStr)
 
void SetHeaderValue (const string &name, const string &value)
 
void SetHeaderValue (const string &name, const struct tm &value)
 
void SetHeaderValue (const string &name, const CTime &value)
 
void RemoveHeaderValue (const string &name)
 
string GetHeaderValue (const string &name) const
 
bool HaveHeaderValue (const string &name) const
 
void SetContentType (const string &type)
 Set content type (text/html by default if not provided) More...
 
string GetContentType (void) const
 Get content type. More...
 
void SetFilename (const string &name, size_t size=0)
 
void SetLocation (const CUrl &url, const IUrlEncoder *encoder=0)
 Set the "Location:" HTTP header. More...
 
void SetMultipartMode (EMultipartMode mode=eMultipart_mixed)
 
EMultipartMode GetMultipartMode (void)
 
void BeginPart (const string &name, const string &type, size_t size=0)
 
void EndPart (void)
 
void EndLastPart (void)
 
void BeginPart (const string &name, const string &type, CNcbiOstream &os, size_t size=0)
 
void EndPart (CNcbiOstream &os)
 
void EndLastPart (CNcbiOstream &os)
 
const CCgiCookiesCookies (void) const
 
CCgiCookiesCookies (void)
 
void SetOutput (CNcbiOstream *os, int fd=-1)
 Set output stream (NULL here means "no output stream"). More...
 
CNcbiOstreamGetOutput (void) const
 Get output stream (NULL here means "no output stream"). More...
 
int GetOutputFD (void) const
 Get file descriptor of the output stream (-1 if not applicable) More...
 
CNcbiOstreamout (void) const
 Get output stream. Throw exception if GetOutput() is NULL. More...
 
void Flush (void) const
 Flush output stream. More...
 
CNcbiOstreamWriteHeader (void) const
 Write HTTP response header to the output stream. More...
 
CNcbiOstreamWriteHeader (CNcbiOstream &os) const
 
bool IsHeaderWritten () const
 
void RequireWriteHeader (bool require)
 Define if WriteHeader() must be called or can be skipped. More...
 
void SetTrackingCookie (const string &name, const string &value, const string &domain, const string &path, const CTime &exp_time=CTime())
 
void DisableTrackingCookie (void)
 
void SetThrowOnBadOutput (bool throw_on_bad_output)
 If set to TRUE then the writes to a "bad" output stream will throw exceptions of type std::ios_base::failure. More...
 
void SetExceptionAfterHEAD (bool expt_after_head)
 
bool AcceptRangesBytes (void) const
 Check if 'Accept-Ranges' header is set to 'bytes'. More...
 
bool HaveContentRange (void) const
 Check if 'Content-Range' header is set. More...
 
void InitCORSHeaders (const string &origin, const string &jquery_callback=kEmptyStr)
 This method is called automatically by CCgiContext. More...
 
void SetRequestMethod (CCgiRequest::ERequestMethod method)
 Set HTTP request method. More...
 
void Finalize (void) const
 Called by the CGI framework after a ProcessRequest(), unless the latter threw an exception. More...
 
void SetRetryContext (const CRetryContext &ctx)
 Set retry headers from the context. More...
 
void SetCgiRequest (const CCgiRequest &request)
 
bool GetChunkedTransferEnabled (void) const
 Check/change chunked transfer encoding status. More...
 
void SetChunkedTransferEnabled (bool value)
 
void FinishChunkedTransfer (void)
 Finish chunked transfer, append zero chunk and trailers, if any. More...
 
void AbortChunkedTransfer (void)
 Abort chunked transfer, block any writes to the output stream. More...
 
bool CanSendTrailer (void) const
 Check if trailer can be sent: chunked transfer must be enabled and the request's TE header must include 'trailers'. More...
 
void AddTrailer (const string &name)
 Prepare to send trailer. More...
 
void RemoveTrailer (const string &name)
 Remove trailer. Must be called before WriteHeader(). More...
 
bool HaveTrailer (const string &name) const
 Check if trailer has been added and its value can be set. More...
 
string GetTrailerValue (const string &name) const
 Get current trailer value. More...
 
void SetTrailerValue (const string &name, const string &value)
 Set trailer value. More...
 
void x_SetSession (const CCgiSession &session)
 

Static Public Member Functions

static size_t GetChunkSize (void)
 

Protected Types

typedef map< string, string, PNocaseTMap
 

Protected Member Functions

 CCgiResponse (const CCgiResponse &)
 
CCgiResponseoperator= (const CCgiResponse &)
 

Protected Attributes

bool m_IsRawCgi
 
EMultipartMode m_IsMultipart
 
bool m_BetweenParts
 
string m_Boundary
 
TMap m_HeaderValues
 
TMap m_TrailerValues
 
CCgiCookies m_Cookies
 
CNcbiOstreamm_Output
 
int m_OutputFD
 
bool m_HeaderWritten
 
bool m_RequireWriteHeader
 
CNcbiOstream::iostate m_OutputExpt
 
CCgiRequest::ERequestMethod m_RequestMethod
 

Static Protected Attributes

static const char * sm_ContentTypeName = "Content-Type"
 
static const char * sm_LocationName = "Location"
 
static const char * sm_ContentTypeDefault = "text/html"
 
static const char * sm_ContentTypeMixed = "multipart/mixed"
 
static const char * sm_ContentTypeRelated = "multipart/related"
 
static const char * sm_ContentTypeXMR = "multipart/x-mixed-replace"
 
static const char * sm_ContentDispoName = "Content-Disposition"
 
static const char * sm_FilenamePrefix = "attachment; filename=\""
 
static const char * sm_HTTPStatusName = "Status"
 
static const char * sm_HTTPStatusDefault = "200 OK"
 
static const char * sm_BoundaryPrefix = "NCBI_CGI_Boundary_"
 
static const char * sm_CacheControl = "Cache-Control"
 
static const char * sm_AcceptRanges = "Accept-Ranges"
 
static const char * sm_AcceptRangesBytes = "bytes"
 
static const char * sm_ContentRange = "Content-Range"
 

Private Member Functions

void x_RestoreOutputExceptions (void)
 
bool x_ValidateHeader (const string &name, const string &value) const
 
 NCBI_PARAM_DECL (bool, CGI, ThrowOnBadOutput)
 
typedef NCBI_PARAM_TYPE (CGI, ThrowOnBadOutput) TCGI_ThrowOnBadOutput
 
 NCBI_PARAM_DECL (bool, CGI, ExceptionAfterHEAD)
 
typedef NCBI_PARAM_TYPE (CGI, ExceptionAfterHEAD) TCGI_ExceptionAfterHEAD
 

Static Private Member Functions

static bool x_ClientSupportsChunkedTransfer (const CNcbiEnvironment &env)
 

Private Attributes

const CCgiSessionm_Session
 
unique_ptr< CCgiCookiem_TrackingCookie
 
bool m_DisableTrackingCookie
 
TCGI_ThrowOnBadOutput m_ThrowOnBadOutput
 
TCGI_ExceptionAfterHEAD m_ExceptionAfterHEAD
 
const CCgiRequestm_Request
 
bool m_ChunkedTransfer
 
unique_ptr< boolm_TrailerEnabled
 
string m_JQuery_Callback
 

Friends

class CCgiContext
 
class CCgiApplication
 

Detailed Description

Definition at line 53 of file ncbicgir.hpp.


The documentation for this class was generated from the following files:
Modified on Thu Apr 11 15:09:58 2024 by modify_doxy.py rev. 669887