00001
00002
00003 #include "gBNetHttpRequest.h"
00004
00005 gHttpRequestList::gHttpRequestList ()
00006 : iContentLength( -1 )
00007 {
00008 }
00009
00010 unsigned gHttpRequestList::FindHeadFirst (char* colonStr)
00011 {
00012 gString sColon;
00013 thisAdjustColonStr( colonStr, sColon );
00014 return
00015 FindFirst( sColon.Str(), 1, e_FindExactPosition );
00016 }
00017
00018 unsigned gHttpRequestList::FindHeadFullFirst (char* fullStrWithColon)
00019 {
00020 unsigned pos;
00021 gString sColon;
00022 thisAdjustColonStr( fullStrWithColon, sColon );
00023 pos = sColon.Find( ": " );
00024 if ( pos==0 ) return 0;
00025 ASSERTION(pos,"pos");
00026 sColon[ pos+2 ] = 0;
00027 DBGPRINT("DBG: FindHeadFullFirst('%s'): '%s'\n",
00028 fullStrWithColon,
00029 sColon.Str());
00030 return
00031 FindFirst( sColon.Str(), 1, e_FindExactPosition );
00032 }
00033
00034 gHttpRequestList& gHttpRequestList::CopyRequest (gHttpRequestList& lReq)
00035 {
00036 iContentLength = lReq.iContentLength;
00037 CopyList( lReq );
00038 lText.CopyList( lReq.lText );
00039 return *this;
00040 }
00041
00042 bool gHttpRequestList::Consolidate ()
00043 {
00044 gString sFirstTextLine( lText.Str(1) );
00045 t_int32 iLengthTry = (t_int32)sFirstTextLine.Length();
00046 long len = (long)iLengthTry;
00047
00048 if ( iContentLength<=-1 ) {
00049 if ( iLengthTry<=0 ) return false;
00050 gString s( 100, '\0' );
00051 snprintf( s.Str(), 100, "Content-Length: %ld", len );
00052 Add( s );
00053 iContentLength = iLengthTry;
00054 }
00055
00056 return true;
00057 }
00058
00059 int gHttpRequestList::thisAdjustColonStr (char* colonStr, gString& sColon)
00060 {
00061
00062 ASSERTION(colonStr,"colonStr");
00063 sColon.Set( colonStr );
00064 if ( sColon[ sColon.Length() ]!=':' )
00065 return 0;
00066 sColon.Add( ' ' );
00067 return 1;
00068 }
00069
00070