Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cHttpProtocolStreamBase Class Reference

#include <cHttpProtocolStream.h>

Inheritance diagram for GrayLib::cHttpProtocolStreamBase:
GrayLib::cProtocolStream GrayLib::cHttpCommon GrayLib::cHttpProtocolStream GrayLib::cHttpScriptedProtocolStream

Public Member Functions

 cHttpProtocolStreamBase (cHttpFactory *pFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut)
 
virtual ~cHttpProtocolStreamBase ()
 
HRESULT ServePageError (cStringA sURLFailed, HTTPRET_TYPE eRetCode)
 
HRESULT ServePageGenericNoChange (const FILECHAR_t *pszSrcFile)
 
HRESULT ServePageStream (cHttpHeaderServer &Head, cStreamInput *pInp)
 
HRESULT ServePageQueue (const ATOMCHAR_t *pszURL, MIME_TYPE eMimeType, cStream &src)
 
HRESULT ServePageFile (const FILECHAR_t *pszSrcFile, MIME_TYPE eMimeType=MIME_UNKNOWN, cTimeInt *pdateIfModifiedSince=nullptr, bool bHeaderOnly=false)
 
virtual HRESULT ProcessStreamPacket () override
 
- Public Member Functions inherited from GrayLib::cProtocolStream
 cProtocolStream (IProtocolFactory *pProtocolFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut)
 
virtual ~cProtocolStream ()
 
HASHCODE_t get_HashCode () const noexcept
 
 STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept override
 
 STDMETHOD_ (cString, get_Name)() const override
 
 STDMETHOD_ (cStringA, get_SymName)() const override
 
bool isConnected () const
 
cStreamInputget_StreamInp () const
 
cStreamOutputget_StreamOut () const
 
virtual size_t get_ProtocolMaxMessageSize () const
 
virtual HRESULT DisposeThis ()
 
virtual HRESULT OnTickStream ()
 
- Public Member Functions inherited from GrayLib::cHttpCommon
 UNITTEST_FRIEND (cHttpCommon)
 

Protected Attributes

cHttpFactory *const m_pFactory
 my parent HTTP server. it created me for cNetServer. More...
 
- Protected Attributes inherited from GrayLib::cProtocolStream
cStreamInputm_pStreamInp
 for use with ProcessStreamPacket() More...
 
cStreamOutputm_pStreamOut
 TX responses back to the remote client go here. (e.g. cNetServerConnection->cNetStream) More...
 
cString m_sName
 a user readable name. Usually the IP address or reverse DNS lookup. can be upgraded as lookup or login becomes avail. m_pClient->get_Name() More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GrayLib::cHttpCommon
static HTTPVERB_TYPE GRAYCALL FindVerb (const char *pszVerb)
 
static HTTPRET_TYPE GRAYCALL GetErrorHttpRet (HRESULT hRes)
 
static HRESULT GRAYCALL GetErrorHResult (HTTPRET_TYPE eRetCode)
 
static cStringA GRAYCALL GetErrorText (HTTPRET_TYPE eRetCode)
 
- Public Attributes inherited from GrayLib::cProtocolStream
IProtocolFactory *const m_pProtocolFactory
 What IProtocolFactory produced this? More...
 
IUnkObject *const m_pServerConnection
 the cNetServerConnection or other top level parent for this protocol. More...
 
HASHCODE_t const m_nHashCode
 the m_pClient->get_HashCode() id for this client connection/stream. More...
 
- Static Public Attributes inherited from GrayLib::cHttpCommon
static const size_t k_CR_SIZE = 2
 sizeof HTTP_CR "\r\n" More...
 
static const char * k_Space = "&nbsp;"
 "&nbsp;" More...
 
static const char *const k_szVerbs [HTTPVERB_QTY+1]
 
static const cPairT< HTTPRET_TYPE, HRESULTk_HttpReturnErrors []
 

Detailed Description

The HTTP servers side of a HTTP client connection. via cHttpFactory base for cHttpProtocolStream

Constructor & Destructor Documentation

◆ cHttpProtocolStreamBase()

GrayLib::cHttpProtocolStreamBase::cHttpProtocolStreamBase ( cHttpFactory pFactory,
IUnkObject *  pServerConnection,
cStreamInput pStreamInp,
cStreamOutput pStreamOut 
)

◆ ~cHttpProtocolStreamBase()

GrayLib::cHttpProtocolStreamBase::~cHttpProtocolStreamBase ( )
virtual

Member Function Documentation

◆ ProcessStreamPacket()

HRESULT GrayLib::cHttpProtocolStreamBase::ProcessStreamPacket ( )
overridevirtual

override cProtocolStream Get the incoming HTTP request from the remote client peer. Parse it and try to respond to it.

Returns
S_OK = processed a single message. <0 = error. HRESULT_WIN32_C(ERROR_IO_INCOMPLETE) = not complete message.

Reimplemented from GrayLib::cProtocolStream.

◆ ServePageError()

HRESULT GrayLib::cHttpProtocolStreamBase::ServePageError ( cStringA  sURLFailed,
HTTPRET_TYPE  eRetCode 
)

Serve up a default error page for this server. virtual allows custom server error pages.

  • pszFailedRequest = the name of the page i just tried to get that caused the error? eRetCode = HTTPRET_ER_404
    Returns
    length of bytes written.

◆ ServePageFile()

HRESULT GrayLib::cHttpProtocolStreamBase::ServePageFile ( const FILECHAR_t pszSrcFile,
MIME_TYPE  eMimeType = MIME_UNKNOWN,
cTimeInt pdateIfModifiedSince = nullptr,
bool  bHeaderOnly = false 
)

Serve the data from the local file system directly. (no template translation) Get proper Last-Modified: time. HTTP_TAG_IfModifiedSince

Returns
HTTPRET_TYPE Code.

◆ ServePageGenericNoChange()

HRESULT GrayLib::cHttpProtocolStreamBase::ServePageGenericNoChange ( const FILECHAR_t pszSrcFile)

Send response that the page has not changed. return 304 (not modified) if the "If-Modified-Since" is not true. "\r\n" = 0d0a

Returns
length sent.

◆ ServePageQueue()

HRESULT GrayLib::cHttpProtocolStreamBase::ServePageQueue ( const ATOMCHAR_t pszURL,
MIME_TYPE  eMimeType,
cStream src 
)

Send a cStreamQueue (maybe memory blob) as a response to a request.

◆ ServePageStream()

HRESULT GrayLib::cHttpProtocolStreamBase::ServePageStream ( cHttpHeaderServer Head,
cStreamInput pInp 
)

Send the response (via cStreamInput source) to some request from the client. ASSUME HTTP_TAG_ContentLength is already set in cHttpHeaderServer.

Todo:
send HTTP compressed or chunked ?

Member Data Documentation

◆ m_pFactory

cHttpFactory* const GrayLib::cHttpProtocolStreamBase::m_pFactory
protected

my parent HTTP server. it created me for cNetServer.


The documentation for this class was generated from the following files: