SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
THttpResp Class Reference

#include <http.h>

Collaboration diagram for THttpResp:

Public Member Functions

 THttpResp (const int &_StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr)
 
 THttpResp (const PSIn &SIn)
 
 ~THttpResp ()
 
 THttpResp (TSIn &)
 
void Save (TSOut &)
 
THttpRespoperator= (const THttpResp &)
 
bool IsOk () const
 
int Len () const
 
bool IsContLenOk () const
 
void GetAsMem (TMem &Mem) const
 
TStr GetHdStr () const
 
const TMemGetBodyAsMem () const
 
TStr GetBodyAsStr () const
 
PSIn GetBodyAsSIn () const
 
int GetStatusCd () const
 
TStr GetReasonPhrase () const
 
int GetFlds () const
 
int GetFldVals (const int &FldN) const
 
void GetFldNmVal (const int &FldN, TStr &FldNm, TStr &FldVal)
 
void GetFldNmVal (const int &FldN, const int &ValN, TStr &FldNm, TStr &FldVal)
 
bool IsFldNm (const TStr &FldNm) const
 
TStr GetFldVal (const TStr &FldNm, const int &ValN=0) const
 
void GetFldValV (const TStr &FldNm, TStrV &FldValV) const
 
bool IsFldVal (const TStr &FldNm, const TStr &FldVal) const
 
void AddFldVal (const TStr &FldNm, const TStr &FldVal)
 
bool IsStatusCd_Ok () const
 
bool IsStatusCd_Redir () const
 
bool IsContType () const
 
bool IsContType (const TStr &ContTypeStr) const
 
bool IsContLen (int &ContLen) const
 
TStr GetSrvNm () const
 
void GetCookieKeyValDmPathQuV (TStrQuV &CookieKeyValDmPathQuV)
 
int GetTxtLen () const
 
void SaveTxt (const PSOut &SOut) const
 
void SaveBody (const PSOut &SOut) const
 
PSIn GetSIn () const
 

Static Public Member Functions

static PHttpResp New (const int &StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr=TStr())
 
static PHttpResp New (const PSIn &SIn)
 
static PHttpResp Load (TSIn &)
 
static PHttpResp LoadTxt (PSIn &SIn)
 

Private Member Functions

void AddHdFld (const TStr &FldNm, const TStr &FldVal, TChA &HdChA)
 
void ParseHttpResp (const PSIn &SIn)
 

Private Attributes

TCRef CRef
 
bool Ok
 
int MajorVerN
 
int MinorVerN
 
int StatusCd
 
TStr ReasonPhrase
 
TStrStrVH FldNmToValVH
 
TStr HdStr
 
TMem BodyMem
 

Friends

class TPt< THttpResp >
 

Detailed Description

Definition at line 134 of file http.h.

Constructor & Destructor Documentation

THttpResp::THttpResp ( const int &  _StatusCd,
const TStr ContTypeVal,
const bool &  CacheCtrlP,
const PSIn BodySIn,
const TStr  LocStr 
)

Definition at line 740 of file http.cpp.

References AddHdFld(), BodyMem, TStr::Empty(), TPt< TRec >::Empty(), THttp::GetReasonPhrase(), TInt::GetStr(), HdStr, TSIn::Len(), TMem::LoadMem(), MajorVerN, MinorVerN, ReasonPhrase, and StatusCd.

741  :
742  Ok(true), MajorVerN(1), MinorVerN(0), StatusCd(_StatusCd), ReasonPhrase(),
743  FldNmToValVH(20), HdStr(), BodyMem(){
745  TChA HdChA;
746  // first line
747  HdChA+="HTTP/"; HdChA+=TInt::GetStr(MajorVerN); HdChA+=".";
748  HdChA+=TInt::GetStr(MinorVerN); HdChA+=' ';
749  HdChA+=TInt::GetStr(StatusCd); HdChA+=' ';
750  HdChA+=ReasonPhrase;
751  HdChA+="\r\n";
752  // header fields
753  // server
754  //AddHdFld(THttp::SrvFldNm, "Tralala", HdChA);
755  if (!LocStr.Empty()){
756  AddHdFld("Location", LocStr, HdChA);}
757  if (!BodySIn.Empty()){
758  // content-type
759  AddHdFld(THttp::ContTypeFldNm, ContTypeVal, HdChA);
760  // accept-ranges
761  AddHdFld(THttp::AcceptRangesFldNm, "bytes", HdChA);
762  // content-length
763  TStr ContLenVal=TInt::GetStr(BodySIn->Len());
764  AddHdFld(THttp::ContLenFldNm, ContLenVal, HdChA);
765  // cache-control
766  if (!CacheCtrlP){
767  AddHdFld(THttp::CacheCtrlFldNm, "no-cache", HdChA);}
768  }
769  // header/body separator
770  HdChA+="\r\n";
771  // header/body data
772  HdStr=HdChA;
773  if (!BodySIn.Empty()){
774  TMem::LoadMem(BodySIn, BodyMem);}
775 }
TStr ReasonPhrase
Definition: http.h:139
virtual int Len() const =0
static const TStr ContTypeFldNm
Definition: http.h:12
TStr GetStr() const
Definition: dt.h:1200
int MinorVerN
Definition: http.h:137
TStrStrVH FldNmToValVH
Definition: http.h:140
TStr HdStr
Definition: http.h:141
bool Empty() const
Definition: bd.h:501
static const TStr AcceptRangesFldNm
Definition: http.h:15
int StatusCd
Definition: http.h:138
static TStr GetReasonPhrase(const int &StatusCd)
Definition: http.cpp:62
static const TStr CacheCtrlFldNm
Definition: http.h:16
static const TStr ContLenFldNm
Definition: http.h:13
static void LoadMem(const PSIn &SIn, TMem &Mem)
Definition: dt.h:149
int MajorVerN
Definition: http.h:137
Definition: dt.h:201
bool Ok
Definition: http.h:136
Definition: dt.h:412
bool Empty() const
Definition: dt.h:491
TMem BodyMem
Definition: http.h:142
void AddHdFld(const TStr &FldNm, const TStr &FldVal, TChA &HdChA)
Definition: http.cpp:693

Here is the call graph for this function:

THttpResp::THttpResp ( const PSIn SIn)

Definition at line 777 of file http.cpp.

References Ok, and ParseHttpResp().

777  :
778  Ok(false), MajorVerN(0), MinorVerN(0), StatusCd(-1), ReasonPhrase(),
779  FldNmToValVH(20), HdStr(), BodyMem(){
780  try {
781  ParseHttpResp(SIn);
782  }
783  catch (const THttpEx&){Ok=false;}
784 }
TStr ReasonPhrase
Definition: http.h:139
int MinorVerN
Definition: http.h:137
TStrStrVH FldNmToValVH
Definition: http.h:140
TStr HdStr
Definition: http.h:141
int StatusCd
Definition: http.h:138
void ParseHttpResp(const PSIn &SIn)
Definition: http.cpp:699
int MajorVerN
Definition: http.h:137
bool Ok
Definition: http.h:136
TMem BodyMem
Definition: http.h:142

Here is the call graph for this function:

THttpResp::~THttpResp ( )
inline

Definition at line 155 of file http.h.

155 {}
THttpResp::THttpResp ( TSIn )
inline

Definition at line 156 of file http.h.

References Fail.

156 {Fail;}
#define Fail
Definition: bd.h:238

Member Function Documentation

void THttpResp::AddFldVal ( const TStr FldNm,
const TStr FldVal 
)

Definition at line 813 of file http.cpp.

References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), FldNmToValVH, THttpLx::GetNrStr(), HdStr, TStr::IsSuffix(), and TChA::Pop().

813  {
814  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
815  FldNmToValVH.AddDat(NrFldNm).Add(FldVal);
816  if (HdStr.IsSuffix("\r\n\r\n")){
817  TChA HdChA=HdStr;
818  HdChA.Pop(); HdChA.Pop();
819  HdChA+=NrFldNm; HdChA+=": "; HdChA+=FldVal;
820  HdChA+="\r\n\r\n";
821  HdStr=HdChA;
822  }
823 }
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStrStrVH FldNmToValVH
Definition: http.h:140
TStr HdStr
Definition: http.h:141
bool IsSuffix(const char *Str) const
Definition: dt.cpp:1093
Definition: dt.h:201
Definition: dt.h:412
char Pop()
Definition: dt.h:265
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

void THttpResp::AddHdFld ( const TStr FldNm,
const TStr FldVal,
TChA HdChA 
)
private

Definition at line 693 of file http.cpp.

References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), FldNmToValVH, and THttpLx::GetNrStr().

Referenced by THttpResp().

693  {
694  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
695  FldNmToValVH.AddDat(NrFldNm).Add(FldVal);
696  HdChA+=FldNm; HdChA+=": "; HdChA+=FldVal; HdChA+="\r\n";
697 }
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStrStrVH FldNmToValVH
Definition: http.h:140
Definition: dt.h:412
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

void THttpResp::GetAsMem ( TMem Mem) const
inline

Definition at line 166 of file http.h.

References TMem::Clr().

166  {
167  Mem.Clr(); Mem+=HdStr; Mem+=BodyMem;}
TStr HdStr
Definition: http.h:141
TMem BodyMem
Definition: http.h:142
void Clr(const bool &DoDel=true)
Definition: dt.h:131

Here is the call graph for this function:

const TMem& THttpResp::GetBodyAsMem ( ) const
inline

Definition at line 169 of file http.h.

169 {return BodyMem;}
TMem BodyMem
Definition: http.h:142
PSIn THttpResp::GetBodyAsSIn ( ) const
inline

Definition at line 171 of file http.h.

171 {return BodyMem.GetSIn(); }
PSIn GetSIn() const
Definition: dt.h:146
TMem BodyMem
Definition: http.h:142
TStr THttpResp::GetBodyAsStr ( ) const
inline

Definition at line 170 of file http.h.

Referenced by TWebPg::IsTxt().

170 {return BodyMem.GetAsStr(' ');}
TStr GetAsStr(const char &NewNullCh='\0') const
Definition: dt.cpp:303
TMem BodyMem
Definition: http.h:142

Here is the caller graph for this function:

void THttpResp::GetCookieKeyValDmPathQuV ( TStrQuV CookieKeyValDmPathQuV)

Definition at line 825 of file http.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), TStr::Empty(), GetFldValV(), TStr::GetTrunc(), TStr::IsChIn(), TVec< TVal, TSizeTy >::Len(), TStr::SplitOnAllCh(), and TStr::ToTrunc().

825  {
826  CookieKeyValDmPathQuV.Clr();
827  TStrV CookieFldValV; GetFldValV(THttp::SetCookieFldNm, CookieFldValV);
828  for (int CookieN=0; CookieN<CookieFldValV.Len(); CookieN++){
829  TStr CookieFldVal=CookieFldValV[CookieN];
830  TStrV KeyValStrV;
831  CookieFldVal.SplitOnAllCh(';', KeyValStrV, true);
832  TStrPrV KeyValPrV; TStr DmNm; TStr PathStr;
833  for (int KeyValStrN=0; KeyValStrN<KeyValStrV.Len(); KeyValStrN++){
834  TStr KeyValStr=KeyValStrV[KeyValStrN];
835  TStr KeyNm; TStr ValStr;
836  if (KeyValStr.IsChIn('=')){
837  KeyValStrV[KeyValStrN].SplitOnCh(KeyNm, '=', ValStr);
838  KeyNm.ToTrunc(); ValStr.ToTrunc();
839  } else {
840  KeyNm=KeyValStr.GetTrunc();
841  }
842  if (KeyNm=="expires"){}
843  else if (KeyNm=="domain"){DmNm=ValStr;}
844  else if (KeyNm=="path"){PathStr=ValStr;}
845  else if (KeyNm=="expires"){}
846  else if (KeyNm=="secure"){}
847  else if (KeyNm=="httponly"){}
848  else if (!KeyNm.Empty()){
849  KeyValPrV.Add(TStrPr(KeyNm, ValStr));
850  }
851  }
852  for (int KeyValPrN=0; KeyValPrN<KeyValPrV.Len(); KeyValPrN++){
853  TStr KeyNm=KeyValPrV[KeyValPrN].Val1;
854  TStr ValStr=KeyValPrV[KeyValPrN].Val2;
855  CookieKeyValDmPathQuV.Add(TStrQu(KeyNm, ValStr, DmNm, PathStr));
856  }
857  }
858 }
TQuad< TStr, TStr, TStr, TStr > TStrQu
Definition: ds.h:262
TPair< TStr, TStr > TStrPr
Definition: ds.h:107
void GetFldValV(const TStr &FldNm, TStrV &FldValV) const
Definition: http.cpp:800
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
TStr GetTrunc() const
Definition: dt.h:509
Definition: dt.h:412
bool Empty() const
Definition: dt.h:491
bool IsChIn(const char &Ch) const
Definition: dt.h:556
TStr & ToTrunc()
Definition: dt.cpp:770
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
static const TStr SetCookieFldNm
Definition: http.h:22

Here is the call graph for this function:

void THttpResp::GetFldNmVal ( const int &  FldN,
TStr FldNm,
TStr FldVal 
)
inline

Definition at line 177 of file http.h.

177  {
178  FldNm=FldNmToValVH.GetKey(FldN); FldVal=FldNmToValVH[FldN][0];}
TStrStrVH FldNmToValVH
Definition: http.h:140
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252
void THttpResp::GetFldNmVal ( const int &  FldN,
const int &  ValN,
TStr FldNm,
TStr FldVal 
)
inline

Definition at line 179 of file http.h.

179  {
180  FldNm=FldNmToValVH.GetKey(FldN); FldVal=FldNmToValVH[FldN][ValN];}
TStrStrVH FldNmToValVH
Definition: http.h:140
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252
int THttpResp::GetFlds ( ) const
inline

Definition at line 174 of file http.h.

174 {return FldNmToValVH.Len();}
TStrStrVH FldNmToValVH
Definition: http.h:140
int Len() const
Definition: hash.h:228
TStr THttpResp::GetFldVal ( const TStr FldNm,
const int &  ValN = 0 
) const

Definition at line 790 of file http.cpp.

References FldNmToValVH, THash< TKey, TDat, THashFunc >::GetDat(), THttpLx::GetNrStr(), THash< TKey, TDat, THashFunc >::IsKey(), and TVec< TVal, TSizeTy >::Len().

Referenced by IsFldVal().

790  {
791  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
792  if (FldNmToValVH.IsKey(NrFldNm)){
793  const TStrV& ValV=FldNmToValVH.GetDat(NrFldNm);
794  if (ValV.Len()>0){return ValV[ValN];} else {return TStr();}
795  } else {
796  return TStr();
797  }
798 }
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStrStrVH FldNmToValVH
Definition: http.h:140
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:412
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

Here is the caller graph for this function:

int THttpResp::GetFldVals ( const int &  FldN) const
inline

Definition at line 175 of file http.h.

175  {
176  return FldNmToValVH[FldN].Len();}
TStrStrVH FldNmToValVH
Definition: http.h:140
int Len() const
Definition: hash.h:228
void THttpResp::GetFldValV ( const TStr FldNm,
TStrV FldValV 
) const

Definition at line 800 of file http.cpp.

References TVec< TVal, TSizeTy >::Clr(), FldNmToValVH, THash< TKey, TDat, THashFunc >::GetDat(), THttpLx::GetNrStr(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by GetCookieKeyValDmPathQuV().

800  {
801  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
802  if (FldNmToValVH.IsKey(NrFldNm)){
803  FldValV=FldNmToValVH.GetDat(NrFldNm);
804  } else {
805  FldValV.Clr();
806  }
807 }
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStrStrVH FldNmToValVH
Definition: http.h:140
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
Definition: dt.h:412
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

Here is the caller graph for this function:

TStr THttpResp::GetHdStr ( ) const
inline

Definition at line 168 of file http.h.

168 {return HdStr;}
TStr HdStr
Definition: http.h:141
TStr THttpResp::GetReasonPhrase ( ) const
inline

Definition at line 173 of file http.h.

References THttp::GetReasonPhrase().

int StatusCd
Definition: http.h:138
static TStr GetReasonPhrase(const int &StatusCd)
Definition: http.cpp:62

Here is the call graph for this function:

PSIn THttpResp::GetSIn ( ) const

Definition at line 860 of file http.cpp.

References BodyMem, HdStr, TMem::Len(), TStr::Len(), and TSOut::PutStr().

860  {
861  TMOut MOut(HdStr.Len()+BodyMem.Len());
862  MOut.PutStr(HdStr); MOut.PutMem(BodyMem);
863  return MOut.GetSIn();
864 }
int Len() const
Definition: dt.h:490
TStr HdStr
Definition: http.h:141
int Len() const
Definition: dt.h:134
Definition: fl.h:495
TMem BodyMem
Definition: http.h:142
int PutStr(const char *CStr)
Definition: fl.cpp:117

Here is the call graph for this function:

TStr THttpResp::GetSrvNm ( ) const
inline

Definition at line 198 of file http.h.

References THttp::SrvFldNm.

198  {
199  return GetFldVal(THttp::SrvFldNm);}
TStr GetFldVal(const TStr &FldNm, const int &ValN=0) const
Definition: http.cpp:790
static const TStr SrvFldNm
Definition: http.h:18
int THttpResp::GetStatusCd ( ) const
inline

Definition at line 172 of file http.h.

172 {return StatusCd;}
int StatusCd
Definition: http.h:138
int THttpResp::GetTxtLen ( ) const
inline

Definition at line 202 of file http.h.

202 {return HdStr.Len()+BodyMem.Len();}
int Len() const
Definition: dt.h:490
TStr HdStr
Definition: http.h:141
int Len() const
Definition: dt.h:134
TMem BodyMem
Definition: http.h:142
bool THttpResp::IsContLen ( int &  ContLen) const
inline

Definition at line 196 of file http.h.

References THttp::ContLenFldNm.

196  {
197  return GetFldVal(THttp::ContLenFldNm).IsInt(ContLen);}
bool IsInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
Definition: dt.cpp:1159
TStr GetFldVal(const TStr &FldNm, const int &ValN=0) const
Definition: http.cpp:790
static const TStr ContLenFldNm
Definition: http.h:13
bool THttpResp::IsContLenOk ( ) const
inline

Definition at line 164 of file http.h.

164  {int ContLen;
165  return IsOk()&&IsContLen(ContLen)&&(ContLen==BodyMem.Len());}
int Len() const
Definition: dt.h:134
bool IsContLen(int &ContLen) const
Definition: http.h:196
bool IsOk() const
Definition: http.h:162
TMem BodyMem
Definition: http.h:142
bool THttpResp::IsContType ( ) const
inline

Definition at line 192 of file http.h.

References THttp::ContTypeFldNm.

Referenced by TWebPg::IsTxt().

192  {
193  return IsFldNm(THttp::ContTypeFldNm);}
static const TStr ContTypeFldNm
Definition: http.h:12
bool IsFldNm(const TStr &FldNm) const
Definition: http.cpp:786

Here is the caller graph for this function:

bool THttpResp::IsContType ( const TStr ContTypeStr) const
inline

Definition at line 194 of file http.h.

References THttp::ContTypeFldNm.

194  {
195  return GetFldVal(THttp::ContTypeFldNm).IsStrIn(ContTypeStr);}
static const TStr ContTypeFldNm
Definition: http.h:12
TStr GetFldVal(const TStr &FldNm, const int &ValN=0) const
Definition: http.cpp:790
bool IsStrIn(const TStr &Str) const
Definition: dt.h:557
bool THttpResp::IsFldNm ( const TStr FldNm) const

Definition at line 786 of file http.cpp.

References FldNmToValVH, THttpLx::GetNrStr(), and THash< TKey, TDat, THashFunc >::IsKey().

786  {
787  return FldNmToValVH.IsKey(THttpLx::GetNrStr(FldNm));
788 }
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStrStrVH FldNmToValVH
Definition: http.h:140
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

bool THttpResp::IsFldVal ( const TStr FldNm,
const TStr FldVal 
) const

Definition at line 809 of file http.cpp.

References GetFldVal(), and THttpLx::GetNrStr().

809  {
810  return THttpLx::GetNrStr(FldVal)==THttpLx::GetNrStr(GetFldVal(FldNm));
811 }
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStr GetFldVal(const TStr &FldNm, const int &ValN=0) const
Definition: http.cpp:790

Here is the call graph for this function:

bool THttpResp::IsOk ( ) const
inline

Definition at line 162 of file http.h.

162 {return Ok;}
bool Ok
Definition: http.h:136
bool THttpResp::IsStatusCd_Ok ( ) const
inline

Definition at line 187 of file http.h.

References THttp::OkStatusCd.

187  {
188  return IsOk() && (GetStatusCd()/100==THttp::OkStatusCd/100);}
bool IsOk() const
Definition: http.h:162
static const int OkStatusCd
Definition: http.h:48
int GetStatusCd() const
Definition: http.h:172
bool THttpResp::IsStatusCd_Redir ( ) const
inline

Definition at line 189 of file http.h.

References THttp::RedirStatusCd.

189  {
190  return IsOk() && (GetStatusCd()/100==THttp::RedirStatusCd/100);}
static const int RedirStatusCd
Definition: http.h:49
bool IsOk() const
Definition: http.h:162
int GetStatusCd() const
Definition: http.h:172
int THttpResp::Len ( ) const
inline

Definition at line 163 of file http.h.

163 {return HdStr.Len()+BodyMem.Len();}
int Len() const
Definition: dt.h:490
TStr HdStr
Definition: http.h:141
int Len() const
Definition: dt.h:134
TMem BodyMem
Definition: http.h:142
static PHttpResp THttpResp::Load ( TSIn )
inlinestatic

Definition at line 157 of file http.h.

References Fail.

157 {Fail; return NULL;}
#define Fail
Definition: bd.h:238
static PHttpResp THttpResp::LoadTxt ( PSIn SIn)
inlinestatic

Definition at line 203 of file http.h.

203  {
204  return new THttpResp(SIn);}
THttpResp(const int &_StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr)
Definition: http.cpp:740
static PHttpResp THttpResp::New ( const int &  StatusCd,
const TStr ContTypeVal,
const bool &  CacheCtrlP,
const PSIn BodySIn,
const TStr  LocStr = TStr() 
)
inlinestatic

Definition at line 148 of file http.h.

149  {
150  return PHttpResp(new
151  THttpResp(StatusCd, ContTypeVal, CacheCtrlP, BodySIn, LocStr));}
int StatusCd
Definition: http.h:138
THttpResp(const int &_StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr)
Definition: http.cpp:740
TPt< THttpResp > PHttpResp
Definition: http.h:134
static PHttpResp THttpResp::New ( const PSIn SIn)
inlinestatic

Definition at line 153 of file http.h.

153  {
154  return PHttpResp(new THttpResp(SIn));}
THttpResp(const int &_StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr)
Definition: http.cpp:740
TPt< THttpResp > PHttpResp
Definition: http.h:134
THttpResp& THttpResp::operator= ( const THttpResp )
inline

Definition at line 160 of file http.h.

References Fail.

160 {Fail; return *this;}
#define Fail
Definition: bd.h:238
void THttpResp::ParseHttpResp ( const PSIn SIn)
private

Definition at line 699 of file http.cpp.

References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), BodyMem, TMem::Clr(), TStr::Clr(), THttpLx::ClrMemSf(), THttpLx::Eof(), FldNmToValVH, TMem::GetAsStr(), THttpLx::GetCrLf(), THttpLx::GetFldVal(), THttpLx::GetInt(), THttpLx::GetMemSf(), THttpLx::GetNrStr(), THttpLx::GetPeriod(), THttpLx::GetRespReasonPhrase(), THttpLx::GetRest(), THttpLx::GetSpec(), THttpLx::GetToken(), HdStr, THttpLx::IsCrLf(), THttpLx::IsRespStatusLn(), MajorVerN, MinorVerN, Ok, ReasonPhrase, and StatusCd.

Referenced by THttpResp().

699  {
700  THttpLx Lx(SIn);
701  if (Lx.Eof()){
702  // no content
703  MajorVerN=0; MinorVerN=9; StatusCd=204;
704  HdStr.Clr(); BodyMem.Clr();
705  } else {
706  if (Lx.IsRespStatusLn()){
707  // status-line
708  Lx.GetToken(THttp::HttpStr); Lx.GetSpec(THttp::SlashStr);
709  MajorVerN=Lx.GetInt(1); Lx.GetPeriod(); MinorVerN=Lx.GetInt(1);
710  StatusCd=Lx.GetInt(3);
711  ReasonPhrase=Lx.GetRespReasonPhrase();
712  Lx.GetCrLf();
713  // header fields & values
714  while (!Lx.IsCrLf()){
715  TStr FldNm=Lx.GetToken(); Lx.GetSpec(THttp::ColonStr);
716  TStr FldVal=Lx.GetFldVal();
717  Lx.GetCrLf();
718  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
719  FldNmToValVH.AddDat(NrFldNm).Add(FldVal);
720  }
721  // separator CrLf
722  Lx.GetCrLf();
723  // header & body strings
724  HdStr=Lx.GetMemSf().GetAsStr();
725  Lx.ClrMemSf();
726  Lx.GetRest();
727  BodyMem=Lx.GetMemSf();
728  } else {
729  // old fashion format
730  MajorVerN=0; MinorVerN=9; StatusCd=200;
731  HdStr.Clr();
732  Lx.ClrMemSf();
733  Lx.GetRest();
734  BodyMem=Lx.GetMemSf();
735  }
736  }
737  Ok=true;
738 }
TStr ReasonPhrase
Definition: http.h:139
int MinorVerN
Definition: http.h:137
static TStr GetNrStr(const TStr &Str)
Definition: http.cpp:226
TStrStrVH FldNmToValVH
Definition: http.h:140
TStr HdStr
Definition: http.h:141
static const TStr HttpStr
Definition: http.h:8
int StatusCd
Definition: http.h:138
void Clr()
Definition: dt.h:489
static const TStr ColonStr
Definition: http.h:10
static const TStr SlashStr
Definition: http.h:9
int MajorVerN
Definition: http.h:137
bool Ok
Definition: http.h:136
Definition: dt.h:412
TMem BodyMem
Definition: http.h:142
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
void Clr(const bool &DoDel=true)
Definition: dt.h:131

Here is the call graph for this function:

Here is the caller graph for this function:

void THttpResp::Save ( TSOut )
inline

Definition at line 158 of file http.h.

References Fail.

158 {Fail;}
#define Fail
Definition: bd.h:238
void THttpResp::SaveBody ( const PSOut SOut) const
inline

Definition at line 207 of file http.h.

Referenced by TWebPg::SaveAsHttpBody().

207  {
208  BodyMem.SaveMem(SOut);}
void SaveMem(const PSOut &SOut) const
Definition: dt.h:153
TMem BodyMem
Definition: http.h:142

Here is the caller graph for this function:

void THttpResp::SaveTxt ( const PSOut SOut) const
inline

Definition at line 205 of file http.h.

Referenced by TWebPg::SaveAsHttp().

205  {
206  HdStr.SaveTxt(SOut); BodyMem.SaveMem(SOut);}
void SaveMem(const PSOut &SOut) const
Definition: dt.h:153
TStr HdStr
Definition: http.h:141
TMem BodyMem
Definition: http.h:142
void SaveTxt(const PSOut &SOut) const
Definition: dt.h:673

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class TPt< THttpResp >
friend

Definition at line 134 of file http.h.

Member Data Documentation

TMem THttpResp::BodyMem
private

Definition at line 142 of file http.h.

Referenced by GetSIn(), ParseHttpResp(), and THttpResp().

TCRef THttpResp::CRef
private

Definition at line 134 of file http.h.

TStrStrVH THttpResp::FldNmToValVH
private

Definition at line 140 of file http.h.

Referenced by AddFldVal(), AddHdFld(), GetFldVal(), GetFldValV(), IsFldNm(), and ParseHttpResp().

TStr THttpResp::HdStr
private

Definition at line 141 of file http.h.

Referenced by AddFldVal(), GetSIn(), ParseHttpResp(), and THttpResp().

int THttpResp::MajorVerN
private

Definition at line 137 of file http.h.

Referenced by ParseHttpResp(), and THttpResp().

int THttpResp::MinorVerN
private

Definition at line 137 of file http.h.

Referenced by ParseHttpResp(), and THttpResp().

bool THttpResp::Ok
private

Definition at line 136 of file http.h.

Referenced by ParseHttpResp(), and THttpResp().

TStr THttpResp::ReasonPhrase
private

Definition at line 139 of file http.h.

Referenced by ParseHttpResp(), and THttpResp().

int THttpResp::StatusCd
private

Definition at line 138 of file http.h.

Referenced by ParseHttpResp(), and THttpResp().


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