gBHttp.h

Go to the documentation of this file.
00001 #ifndef gBHTTP_X_H
00002 #define gBHTTP_X_H
00003 
00004 #include "ghttp.h"
00005 #include "gBNetHttpRequest.h"
00006 ////////////////////////////////////////////////////////////
00007 class gXHttpReplyHeader : public gList {
00008 public:
00009     gXHttpReplyHeader () ;
00010     virtual ~gXHttpReplyHeader () {
00011     }
00012 
00013     // Public data-members
00014     int htmlCode;
00015     gString sHtmlCode;  // (e.g. "Not Found")
00016     gList kindsL;
00017     gList linesL;
00018 
00019     // I/O methods
00020     virtual bool IsText () ;
00021     virtual bool IsChunked () {
00022         return isTransferEncodingChunked;
00023     }
00024 
00025     virtual bool GetLine (char* sKind, gString& sResult) ;
00026     virtual bool AddLine (gString& s) ;
00027     virtual t_uint32 GetLength (bool& hasFound, bool& isLengthOk) ;
00028 
00029     virtual bool IsCodeNotFound () {
00030         return htmlCode>=400 && htmlCode<500;
00031     }
00032     virtual bool IsCodeRedirect () {
00033         return htmlCode>=300 && htmlCode<400;
00034     }
00035 
00036 protected:
00037     bool isTransferEncodingChunked;
00038 
00039     int thisAddLine (char* sKind, char* sContent) ;
00040     int thisAddLine (gString& sKind, gString& sContent) ;
00041 
00042 private:
00043     // Operators,empty
00044     gXHttpReplyHeader (gXHttpReplyHeader& ) ; //empty
00045     gXHttpReplyHeader& operator= (gXHttpReplyHeader& ) ; //empty
00046 };
00047 ////////////////////////////////////////////////////////////
00048 class gXHttpGeneric : public gHttpGeneric {
00049 public:
00050     virtual ~gXHttpGeneric () ;
00051 
00052     // Public data-members
00053     int ioOpErrCode;
00054     gList getHeaderL;  // merely the written header
00055     gList strHeaderL;  // strings to add between 'Host:' and 'User-Agent:'
00056     gXHttpReplyHeader replyHeader;
00057     gHttpRequestList lReq;
00058 
00059     t_uint64 contentBytesRead;
00060     t_uint64 totalBytesRead;
00061     const static short nStat=4;
00062     gUInt vStat[nStat];
00063     int keepAliveTimeout;  // in seconds
00064     int keepAliveMax;  // in seconds
00065     FILE* fRepErr;
00066 
00067     // Get methods
00068     virtual gBigBuffer& GetBuffer () ;
00069     virtual gUCharBuffer& GetBaseBuffer () ;
00070     virtual gString& GetProtocolString () ;
00071     virtual gVersion& GetVersion () ;
00072 
00073     virtual gTcpConnect& Connection () ;
00074     virtual gTcpConnect* ConnectionPtr () ;
00075 
00076     virtual bool GetContent (eContentMethod method,
00077                              gString& sHost,
00078                              gString& sPath,
00079                              gString& sReply) ;
00080 
00081     // Set methods
00082     virtual bool SetProtocolVersion (char* str) ;
00083 
00084     virtual int AddHead (gString& s, bool doCrNl=true) ;
00085     virtual int AddHeadStr (char* str) ;
00086     virtual int WriteHead (bool doFlush=false) ;
00087 
00088     // Special methods
00089     virtual int SecSleep (t_uint32 aSec) ;
00090     virtual int MiliSecSleep (t_uint32 aMiliSec) ;
00091 
00092 protected:
00093     gXHttpGeneric (gTcpConnect& connection) ;
00094 
00095     gBigBuffer* pBuf;
00096     gTimerTic mStat[nStat];  // For stats
00097 
00098     int thisReadHeadReply (gTcpConnect& connection, unsigned& count, gString& sResult) ;
00099 
00100     int thisParseServerReply (gString& sReply, gXHttpReplyHeader& serverReply) ;
00101 
00102 private:
00103     gVersion httpVersion;
00104     gString sProtocol;
00105     gString sProtoVersion;
00106 
00107     // Operators,empty
00108     gXHttpGeneric (gXHttpGeneric& ) ; //empty
00109     gXHttpGeneric& operator= (gXHttpGeneric& ) ; //empty
00110 };
00111 ////////////////////////////////////////////////////////////
00112 class gXHttpCont : public gXHttpGeneric {
00113 public:
00114     gXHttpCont (gTcpConnect& connection) ;
00115     virtual ~gXHttpCont () ;
00116 
00117     // Public members
00118     gString strUserAgent;
00119 
00120     // Get methods
00121     virtual bool IsText () {
00122         return isContText;  //Content-Type: Text...
00123     }
00124     virtual bool GetContent (eContentMethod method,
00125                              gString& sHost,
00126                              gString& sPath,
00127                              gString& sReply) ;
00128 
00129     virtual char* GetHeadUserAgentStr () ;
00130     virtual char* GetHeadRefererStr () ;
00131 
00132 protected:
00133     bool isContText;
00134     gString sHostname;
00135     gString sHeadTempStr;
00136 
00137     virtual int ReadReplyText (gTcpConnect& connection, eContentImport contImport, gBigBuffer& bBuf, unsigned& count) ;
00138     virtual int ReadReplyBin (gTcpConnect& connection, gBigBuffer& bBuf, unsigned& count) ;
00139     int ReadReplyUnsized (gTcpConnect& connection, eContentImport contImport, gBigBuffer& bBuf, unsigned& count) ;
00140     int ReadReplyChunked (gTcpConnect& connection, gBigBuffer& bBuf, unsigned& count) ;
00141 
00142     t_uint32 thisReadChunkSize (gTcpConnect& connection, int& error) ;
00143 
00144     int thisGetHtmlContrl (eContentMethod method,
00145                            gString& sPath,
00146                            gString& sReply) ;
00147 
00148 private:
00149     // Operators,empty
00150     gXHttpCont (gXHttpCont& ) ; //empty
00151     gXHttpCont& operator= (gXHttpCont& ) ; //empty
00152 };
00153 ////////////////////////////////////////////////////////////
00154 #endif //gBHTTP_X_H
00155 

Generated on Sat Aug 18 02:40:51 2007 for xpfweb_v2x lib by  doxygen 1.4.2