home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / internet / httpsvr / reqsock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.0 KB  |  112 lines

  1. // ReqSock.h : interface of the CRequestSocket class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1997-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #define MAX_DIR_FILENAME    24
  14. class CRequest;
  15. class CHttpSvrDoc;
  16.  
  17. class CRequestSocket : public CAsyncSocket
  18. {
  19.     DECLARE_DYNCREATE(CRequestSocket)
  20.     CRequestSocket( void );
  21.  
  22. protected:
  23.     void StuffFileType( void );
  24.     BOOL m_bKeepOpen;
  25.     BOOL m_bWantKeepOpen;
  26.     enum REQSTATUS
  27.     {
  28.         REQ_REQUEST=0, REQ_HEADER, REQ_BODY, REQ_SIMPLE, REQ_DONE
  29.     };
  30.  
  31.     CRequest*   m_pRequest; // request object
  32.  
  33.     CByteArray  m_buf;
  34.     int         m_cbOut;
  35.     CString     m_strLine;
  36.     REQSTATUS   m_reqStatus;
  37.     HANDLE      m_hFile;
  38.     int         m_nRefs;
  39.     BOOL        m_bKilled;
  40.  
  41. public:
  42.     CHttpSvrDoc* m_pDoc;
  43.     BOOL CheckExt( const CString& strExt, CString& strAvail, DWORD dwType );
  44.     BOOL IsSvrApp( void );
  45.     BOOL CheckDefault( UINT uList, BOOL bExecute );
  46.     CString StripLast( CString& strPath );
  47.     int StuffStatus( const CString& strStatus );
  48.     CRequestSocket( CHttpSvrDoc* pDoc );
  49.     ~CRequestSocket( void );
  50.     virtual int AddRef( void );
  51.     virtual int Release( void );
  52.  
  53. #ifdef IMPL_CGI
  54.     BOOL        CGIStart( void );
  55.     void        CGIDone( void );
  56.     CWinThread* m_pThread;
  57.     CEvent*     m_pCancel;
  58. #endif // IMPL_CGI
  59.  
  60. protected:
  61.     BOOL StartSvrApp( void );
  62.     BOOL FromHttpTime( const CString& strHttp, CTime& timeHttp );
  63.     BOOL IfModSince( const CTime& timeIfMod );
  64.     CString GetHttpDate( LPFILETIME pft = NULL );
  65.     BOOL GetLine( const CByteArray& bytes, int nBytes, int& ndx );
  66.     void ProcessLine( void );
  67.     BOOL BodySent( void );
  68.     void AddToBody( int nBytes, int ndx );
  69.     BOOL StartResponse( void );
  70.     BOOL FindTarget( CString& strFile );
  71.     BOOL URLtoPath( CString& strFile );
  72.     BOOL PathToURL( CString& strFile );
  73.     BOOL StuffHeading( void );
  74.     void StartTargetStuff( void );
  75.  
  76.     int StuffString( const CString& );
  77.     int StuffString( UINT uId );
  78.     int StuffStatus( UINT uMsg );
  79.     int StuffError( UINT uMsg );
  80.     int StuffHeader( CString strName, CString strValue );
  81.     int StuffHeader( CString strName, int nValue );
  82.  
  83.     // methods not supported by Mac version....
  84.     void StuffListing( void );
  85.     int  StuffListingFile( WIN32_FIND_DATA* fd, const CString& strDir, BOOL bIcons );
  86.  
  87. protected:
  88.     virtual void OnReceive(int nErrorCode);
  89.     virtual void OnSend(int nErrorCode);
  90.     virtual void OnClose(int nErrorCode);
  91.  
  92.     friend UINT CGIThread( LPVOID );
  93. };
  94.  
  95. CString Decode( const CString& str, BOOL bQuery = FALSE );
  96.  
  97. #ifdef IMPL_CGI
  98. void HeaderToEnvVar( CString& strVar );
  99.  
  100. class CEnvironment
  101. {
  102. public:
  103.     CStringList m_list;
  104.     int         m_nSize;
  105.  
  106.     CEnvironment( void );
  107.     ~CEnvironment( void );
  108.     BOOL Add( CString name, CString value );
  109.     LPVOID GetBlock( void );
  110. };
  111. #endif
  112.