home *** CD-ROM | disk | FTP | other *** search
- /*____________________________________________________________________________*\
- *
-
- Copyright (c) 1997 John Roy. All rights reserved.
-
- These sources, libraries and applications are
- FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
- as long as the following conditions are adhered to.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- 3. Redistributions of any form whatsoever and all advertising materials
- mentioning features must contain the following
- acknowledgment:
- "This product includes software developed by John Roy
- (http://www.johnroy.com/pi3/)."
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
-
- *____________________________________________________________________________*|
- *
- * $Source: PIHTTP.h$
- * $Date: Sun Aug 10 06:36:32 1997$
- *
- Description:
-
- \*____________________________________________________________________________*/
- /* $SourceTop:$ */
-
- #ifndef PIHTTP_H_
- #define PIHTTP_H_
-
- #include "Pi2API.h"
- #include "PIIOBuf.h"
- #include "HTTPDefs.h"
-
- /* -------------- +++++++++++++++++++++++++++++++ ------------------ *\
-
- Internal C++ Interface
-
- \* -------------- +++++++++++++++++++++++++++++++ ------------------ */
- #if defined(__cplusplus) && defined(PI3_INTERNAL)
-
- #include <assert.h>
- #include <stddef.h>
-
- #include "DblList.h" /* --- from Base library --- */
-
- #define HTTP_DB "HTTP DB"
- #define HTTP_REQUEST_DB "HTTP Request DB"
- #define HTTP_RESPONSE_DB "HTTP Response DB"
-
- /*____________________________________________________________________________*\
- *
- Description:
- \*____________________________________________________________________________*/
- class PIHTTP
- {
- public:
- /* --- public constant values --- */
- const int ciPhase;
-
- /* --- public mutable values --- */
- int iStatus;
-
- PIDB *pConnectionDB;
- PIDB *pHostDB;
- PIDB *pRequestDB;
- PIDB *pResponseDB;
- PIIOBuffer *pBuffer;
-
- public:
- /* --- private members, don't access, even though not marked private --- */
- PIHTTP *pParent; /* --- NULL if this is not a subrequest --- */
- PIDB *pDB;
- int iLastResultCode;
- PITimer *pTimer;
- const char *pHandlerName;
- int iDelta; /* --- profile delta of time in handler --- */
- int iDepth; /* --- depth of current request if nested --- */
- DblList lMemoryRecords; /* --- memory records --- */
-
- private:
- /* --- copy constructor will be disallowed --- */
- PIHTTP( const PIHTTP &tH );
-
- /* --- internal methods --- */
- void ClearRequest();
-
- public:
- PIHTTP( PIHTTP *pTheParentRequest );
- PIHTTP( PIObject *pTheIOObject, PIDB *pTheHostDB );
- PIHTTP( PIDB *pHost );
- ~PIHTTP();
-
- /* --- new request --- */
- void NewRequest();
-
- /* ---
- High level data structures that make up a request/response
- cycle
- --- */
- inline PIDB *GetConnectionDB() /* connection DB */
- { return pConnectionDB; };
- inline PIDB *GetHostDB() /* virtual host DB */
- { return pHostDB; };
- inline PIDB *GetDB() /* generic DB */
- { return pDB; };
- inline PIDB *GetRequestDB() /* request specific information */
- { return pRequestDB; };
- inline PIDB *GetResponseDB() /* response specific information */
- { return pResponseDB; };
- inline PIIOBuffer &GetIOBuffer() /* IO buffer object */
- { return *pBuffer; };
- inline int IsSubRequest() /* is this a subrequest? */
- { return pParent!=0; };
-
- /* --- allow the virtual host to be changed --- */
- inline void SetHostDB( PIDB *pNewHostDB )
- { pHostDB = pNewHostDB; };
-
- /* --- non-inline functions --- */
- void *AllocMem( size_t tSize ); /* allocate memory */
-
- };
-
- /* --- inlines --- */
- inline void PIHTTP_disableKeepOpen( PIHTTP &tPIHTTP )
- {
- PIDB_replace( tPIHTTP.GetConnectionDB(), PIDBTYPE_OPAQUE,
- KEY_INT_KEEPOPEN, (void *)0, 0 );
- };
-
- /* -------------- +++++++++++++++++++++++++++++++ ------------------ *\
-
- External C Interface
-
- \* -------------- +++++++++++++++++++++++++++++++ ------------------ */
- #else
- /*____________________________________________________________________________*\
- *
- Description:
- C structure version of C++ class.
- \*____________________________________________________________________________*/
- struct _PIHTTP
- {
- /* --- public constant values --- */
- int ciPhase;
-
- /* --- public mutable values --- */
- int iStatus;
-
- PIDB *pConnectionDB;
- PIDB *pHostDB;
- PIDB *pRequestDB;
- PIDB *pResponseDB;
- PIIOBuffer *pBuffer;
-
- /* --- other members are private --- */
-
- };
- typedef struct _PIHTTP PIHTTP;
-
- #endif
- /* -------------- +++++++++++++++++++++++++++++++ ------------------ *\
-
- C Functions
-
- \* -------------- +++++++++++++++++++++++++++++++ ------------------ */
- /*____________________________________________________________________________*\
- *
- Name:
- PIHTTP_new
-
- Synopsis:
- PIHTTP *PIHTTP_new( PIObject *pIOObject, PIDB *pHostDB )
-
- Description:
- This function is not yet documented.
-
- Notes:
- Return Values:
- Errors:
- See Also:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIHTTP *PIHTTP_new( PIObject *pIOObject, PIDB *pHostDB );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIHTTP_newChild
-
- Synopsis:
- PIHTTP *PIHTTP_newChild( PIHTTP *pParent )
-
- Description:
- This function is not yet documented.
-
- Notes:
- Return Values:
- Errors:
- See Also:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIHTTP *PIHTTP_newChild( PIHTTP *pParent );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIHTTP_delete
-
- Synopsis:
- int PIHTTP_delete( PIHTTP *pPIHTTP )
-
- Description:
- This function is not yet documented.
-
- Notes:
- Return Values:
- Errors:
- See Also:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIHTTP_delete( PIHTTP *pPIHTTP );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIHTTP_allocMem
-
- Synopsis:
- void *PIHTTP_allocMem( PIHTTP *pPIHTTP, unsigned int iSize )
-
- Description:
- This function is not yet documented.
-
- Notes:
- Return Values:
- Errors:
- See Also:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI void *PIHTTP_allocMem( PIHTTP *pPIHTTP, unsigned int iSize );
-
- #endif /* PIHTTP_H_ */
-
-