SNAP Library, Developer Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
http.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  THttp

Enumerations

enum  THttpRqMethod { hrmUndef, hrmGet, hrmHead, hrmPost }

Functions

void ParseSearch (const TStr &SearchStr)
void ParseHttpRq (const PSIn &SIn)
 THttpRq (const PSIn &SIn)
static PHttpRq New (const PSIn &SIn)
 THttpRq (const THttpRqMethod &_Method, const PUrl &_Url, const TStr &ContTypeFldVal, const TMem &_BodyMem, const int &FetchId=-1)
static PHttpRq New (const THttpRqMethod &Method, const PUrl &Url, const TStr &ContTypeFldVal, const TMem &BodyMem)
static PHttpRq New (const PUrl &Url, const int &FetchId=-1)
 ~THttpRq ()
 THttpRq (TSIn &)
static PHttpRq Load (TSIn &)
void Save (TSOut &)
THttpRqoperator= (const THttpRq &)
bool IsOk () const
bool IsComplete () const
THttpRqMethod GetMethod () const
const TStrGetMethodNm () const
PUrl GetUrl () const
PUrlEnv GetUrlEnv () const
bool IsFldNm (const TStr &FldNm) const
TStr GetFldVal (const TStr &FldNm) const
bool IsFldVal (const TStr &FldNm, const TStr &FldVal) const
void AddFldVal (const TStr &FldNm, const TStr &FldVal)
const TStrStrHGetFldValH () const
TStr GetHdStr () const
int GetBodyLen () const
TStr GetBodyAsStr () const
PSIn GetBodyAsSIn () const
void GetBodyAsMem (TMem &Mem) const
void GetAsMem (TMem &Mem) const
bool IsContType (const TStr &ContTypeStr) const
bool IsContLen (int &ContLen) const
TStr GetStr () const
void AddHdFld (const TStr &FldNm, const TStr &FldVal, TChA &HdChA)
void ParseHttpResp (const PSIn &SIn)
 THttpResp (const int &_StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr)
static PHttpResp New (const int &StatusCd, const TStr &ContTypeVal, const bool &CacheCtrlP, const PSIn &BodySIn, const TStr LocStr=TStr())
 THttpResp (const PSIn &SIn)
 ~THttpResp ()
 THttpResp (TSIn &)
THttpRespoperator= (const THttpResp &)
int Len () const
bool IsContLenOk () const
const TMemGetBodyAsMem () 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)
TStr GetFldVal (const TStr &FldNm, const int &ValN=0) const
void GetFldValV (const TStr &FldNm, TStrV &FldValV) const
bool IsStatusCd_Ok () const
bool IsStatusCd_Redir () const
bool IsContType () const
TStr GetSrvNm () const
void GetCookieKeyValDmPathQuV (TStrQuV &CookieKeyValDmPathQuV)
int GetTxtLen () const
static PHttpResp LoadTxt (PSIn &SIn)
void SaveTxt (const PSOut &SOut) const
void SaveBody (const PSOut &SOut) const
PSIn GetSIn () const

Variables

ClassTP(THttpRq, PHttpRq)
private bool 
CompleteP
int MajorVerN
int MinorVerN
THttpRqMethod Method
PUrl Url
TStrStrH FldNmToValH
PUrlEnv UrlEnv
TStr HdStr
TMem BodyMem
int StatusCd
TStr ReasonPhrase
TStrStrVH FldNmToValVH

Enumeration Type Documentation

Enumerator:
hrmUndef 
hrmGet 
hrmHead 
hrmPost 

Definition at line 61 of file http.h.


Function Documentation

void AddFldVal ( const TStr FldNm,
const TStr FldVal 
)

Definition at line 663 of file http.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), FldNmToValH, and THttpLx::GetNrStr().

                                                            {
  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
  FldNmToValH.AddDat(NrFldNm, FldVal);
}

Here is the call graph for this function:

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

Definition at line 692 of file http.cpp.

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

Referenced by THttpResp().

                                                                          {
  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
  FldNmToValVH.AddDat(NrFldNm).Add(FldVal);
  HdChA+=FldNm; HdChA+=": "; HdChA+=FldVal; HdChA+="\r\n";
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GetAsMem ( TMem Mem) const

Definition at line 116 of file http.h.

References BodyMem, and HdStr.

{Mem.Clr(); Mem+=HdStr; Mem+=BodyMem;}
void GetBodyAsMem ( TMem Mem) const

Definition at line 115 of file http.h.

References BodyMem.

{Mem.Clr(); Mem += BodyMem;}
const TMem& GetBodyAsMem ( ) const

Definition at line 165 of file http.h.

References BodyMem.

{return BodyMem;}
PSIn GetBodyAsSIn ( ) const

Definition at line 114 of file http.h.

References BodyMem, and TMemIn::New().

{ return TMemIn::New(BodyMem); }

Here is the call graph for this function:

TStr GetBodyAsStr ( ) const

Definition at line 113 of file http.h.

References BodyMem.

{ return BodyMem.GetAsStr(' ');}
int GetBodyLen ( ) const

Definition at line 112 of file http.h.

References BodyMem.

{ return BodyMem.Len(); }
void THttpResp::GetCookieKeyValDmPathQuV ( TStrQuV CookieKeyValDmPathQuV)

Definition at line 824 of file http.cpp.

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

                                                                      {
  CookieKeyValDmPathQuV.Clr();
  TStrV CookieFldValV; GetFldValV(THttp::SetCookieFldNm, CookieFldValV);
  for (int CookieN=0; CookieN<CookieFldValV.Len(); CookieN++){
    TStr CookieFldVal=CookieFldValV[CookieN];
    TStrV KeyValStrV;
    CookieFldVal.SplitOnAllCh(';', KeyValStrV, true);
    TStrPrV KeyValPrV; TStr DmNm; TStr PathStr;
    for (int KeyValStrN=0; KeyValStrN<KeyValStrV.Len(); KeyValStrN++){
      TStr KeyValStr=KeyValStrV[KeyValStrN];
      TStr KeyNm; TStr ValStr; 
      if (KeyValStr.IsChIn('=')){
        KeyValStrV[KeyValStrN].SplitOnCh(KeyNm, '=', ValStr);
        KeyNm.ToTrunc(); ValStr.ToTrunc();
      } else {
        KeyNm=KeyValStr.GetTrunc();
      }
      if (KeyNm=="expires"){}
      else if (KeyNm=="domain"){DmNm=ValStr;}
      else if (KeyNm=="path"){PathStr=ValStr;}
      else if (KeyNm=="expires"){}
      else if (KeyNm=="secure"){}
      else if (KeyNm=="httponly"){}
      else if (!KeyNm.Empty()){
        KeyValPrV.Add(TStrPr(KeyNm, ValStr));
      }
    }
    for (int KeyValPrN=0; KeyValPrN<KeyValPrV.Len(); KeyValPrN++){
      TStr KeyNm=KeyValPrV[KeyValPrN].Val1;
      TStr ValStr=KeyValPrV[KeyValPrN].Val2;
      CookieKeyValDmPathQuV.Add(TStrQu(KeyNm, ValStr, DmNm, PathStr));
    }
  }
}

Here is the call graph for this function:

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

Definition at line 172 of file http.h.

References FldNmToValVH, and THash< TKey, TDat, THashFunc >::GetKey().

                                                              {
    FldNm=FldNmToValVH.GetKey(FldN); FldVal=FldNmToValVH[FldN][0];}

Here is the call graph for this function:

void GetFldNmVal ( const int &  FldN,
const int &  ValN,
TStr FldNm,
TStr FldVal 
)

Definition at line 174 of file http.h.

References FldNmToValVH, and THash< TKey, TDat, THashFunc >::GetKey().

                                                                               {
    FldNm=FldNmToValVH.GetKey(FldN); FldVal=FldNmToValVH[FldN][ValN];}

Here is the call graph for this function:

int GetFlds ( ) const

Definition at line 169 of file http.h.

References FldNmToValVH, and THash< TKey, TDat, THashFunc >::Len().

{return FldNmToValVH.Len();}

Here is the call graph for this function:

TStr GetFldVal ( const TStr FldNm) const

Referenced by GetSrvNm(), IsContLen(), IsContType(), IsFldVal(), and ParseHttpRq().

Here is the caller graph for this function:

TStr GetFldVal ( const TStr FldNm,
const int &  ValN = 0 
) const
const TStrStrH & THttpRq::GetFldValH ( ) const

Definition at line 668 of file http.cpp.

References FldNmToValH.

                                          {
        return FldNmToValH;
}
int GetFldVals ( const int &  FldN) const

Definition at line 170 of file http.h.

References FldNmToValVH, and THash< TKey, TDat, THashFunc >::Len().

                                        {
    return FldNmToValVH[FldN].Len();}

Here is the call graph for this function:

void THttpResp::GetFldValV ( const TStr FldNm,
TStrV FldValV 
) const

Definition at line 799 of file http.cpp.

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

Referenced by GetCookieKeyValDmPathQuV().

                                                                  {
  TStr NrFldNm=THttpLx::GetNrStr(FldNm);
  if (FldNmToValVH.IsKey(NrFldNm)){
    FldValV=FldNmToValVH.GetDat(NrFldNm);
  } else {
    FldValV.Clr();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr GetHdStr ( ) const

Definition at line 111 of file http.h.

References HdStr.

{return HdStr;}

Definition at line 100 of file http.h.

References Method.

{return Method;}
const TStr& GetMethodNm ( ) const

Referenced by THttpRq().

Here is the caller graph for this function:

TStr GetReasonPhrase ( ) const

Definition at line 168 of file http.h.

References THttp::GetReasonPhrase(), and StatusCd.

Here is the call graph for this function:

PSIn GetSIn ( ) const

Definition at line 136 of file dt.h.

References Bf, TMOut::GetSIn(), and TSOut::SaveBf().

                      {
    TMOut MOut(BfL); MOut.SaveBf(Bf, BfL); return MOut.GetSIn();}

Here is the call graph for this function:

TStr GetSrvNm ( ) const

Definition at line 193 of file http.h.

References GetFldVal(), and THttp::SrvFldNm.

Here is the call graph for this function:

int GetStatusCd ( ) const

Definition at line 167 of file http.h.

References StatusCd.

Referenced by IsStatusCd_Ok(), and IsStatusCd_Redir().

{return StatusCd;}

Here is the caller graph for this function:

TStr GetStr ( ) const

Definition at line 201 of file html.h.

{return Str;}
int GetTxtLen ( ) const

Definition at line 197 of file http.h.

References BodyMem, HdStr, and TStr::Len().

{return HdStr.Len()+BodyMem.Len();}

Here is the call graph for this function:

PUrl GetUrl ( ) const

Definition at line 102 of file http.h.

References Url.

{return Url;}
PUrlEnv GetUrlEnv ( ) const

Definition at line 103 of file http.h.

References UrlEnv.

{return UrlEnv;}
bool IsComplete ( ) const

Definition at line 99 of file http.h.

References CompleteP.

{return CompleteP;}
bool IsContLen ( int &  ContLen) const

Definition at line 121 of file http.h.

References THttp::ContLenFldNm, GetFldVal(), and TStr::IsInt().

Referenced by IsContLenOk().

                                     {
    return GetFldVal(THttp::ContLenFldNm).IsInt(ContLen);}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsContLenOk ( ) const

Definition at line 160 of file http.h.

References BodyMem, IsContLen(), and IsOk().

                           {int ContLen;
    return IsOk()&&IsContLen(ContLen)&&(ContLen==BodyMem.Len());}

Here is the call graph for this function:

bool IsContType ( const TStr ContTypeStr) const

Definition at line 119 of file http.h.

References THttp::ContTypeFldNm, GetFldVal(), and TStr::IsStrIn().

                                                 {
    return GetFldVal(THttp::ContTypeFldNm).IsStrIn(ContTypeStr);}

Here is the call graph for this function:

bool IsContType ( ) const

Definition at line 187 of file http.h.

References THttp::ContTypeFldNm, and IsFldNm().

Here is the call graph for this function:

bool IsFldNm ( const TStr FldNm) const

Definition at line 645 of file http.cpp.

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

Referenced by IsContType(), and ParseHttpRq().

                                             {
  return FldNmToValH.IsKey(THttpLx::GetNrStr(FldNm));
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 658 of file http.cpp.

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

                                                                  {
  return THttpLx::GetNrStr(FldVal)==THttpLx::GetNrStr(GetFldVal(FldNm));
}

Here is the call graph for this function:

bool IsStatusCd_Ok ( ) const

Definition at line 182 of file http.h.

References GetStatusCd(), IsOk(), and THttp::OkStatusCd.

                             {
    return IsOk() && (GetStatusCd()/100==THttp::OkStatusCd/100);}

Here is the call graph for this function:

bool IsStatusCd_Redir ( ) const

Definition at line 184 of file http.h.

References GetStatusCd(), IsOk(), and THttp::RedirStatusCd.

                                {
    return IsOk() && (GetStatusCd()/100==THttp::RedirStatusCd/100);}

Here is the call graph for this function:

int Len ( ) const

Definition at line 159 of file http.h.

References BodyMem, HdStr, and TStr::Len().

{return HdStr.Len()+BodyMem.Len();}

Here is the call graph for this function:

static PHttpResp Load ( TSIn ) [static]

Definition at line 92 of file http.h.

References Fail.

{Fail; return NULL;}
static PHttpResp LoadTxt ( PSIn SIn) [static]

Definition at line 198 of file http.h.

References THttpResp().

                                     {
    return new THttpResp(SIn);}

Here is the call graph for this function:

static PHttpResp New ( const PSIn SIn) [static]

Definition at line 79 of file http.h.

References THttpRq().

                                     {
    return PHttpRq(new THttpRq(SIn));}

Here is the call graph for this function:

static PHttpRq New ( const THttpRqMethod Method,
const PUrl &  Url,
const TStr ContTypeFldVal,
const TMem BodyMem 
) [static]

Definition at line 84 of file http.h.

References THttpRq().

                                                   {
    return PHttpRq(new THttpRq(Method, Url, ContTypeFldVal, BodyMem));}

Here is the call graph for this function:

static PHttpRq New ( const PUrl &  Url,
const int &  FetchId = -1 
) [static]

Definition at line 88 of file http.h.

References hrmGet, THttpRq(), and TMem().

                                                            {
    return PHttpRq(new THttpRq(hrmGet, Url, "", TMem(), FetchId));}

Here is the call graph for this function:

static PHttpResp New ( const int &  StatusCd,
const TStr ContTypeVal,
const bool &  CacheCtrlP,
const PSIn BodySIn,
const TStr  LocStr = TStr() 
) [static]

Definition at line 144 of file http.h.

References THttpResp().

                                                                         {
    return PHttpResp(new
     THttpResp(StatusCd, ContTypeVal, CacheCtrlP, BodySIn, LocStr));}

Here is the call graph for this function:

THttpRq& operator= ( const THttpRq )

Definition at line 95 of file http.h.

References Fail.

{Fail; return *this;}
THttpResp& operator= ( const THttpResp )

Definition at line 156 of file http.h.

References Fail.

{Fail; return *this;}
void THttpResp::ParseHttpResp ( const PSIn SIn)

Definition at line 698 of file http.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), BodyMem, TStr::Clr(), THttpLx::ClrMemSf(), THttpLx::Eof(), FldNmToValVH, 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, ReasonPhrase, and StatusCd.

Referenced by THttpResp().

                                            {
  THttpLx Lx(SIn);
  if (Lx.Eof()){
    // no content
    MajorVerN=0; MinorVerN=9; StatusCd=204;
    HdStr.Clr(); BodyMem.Clr();
  } else {
    if (Lx.IsRespStatusLn()){
      // status-line
      Lx.GetToken(THttp::HttpStr); Lx.GetSpec(THttp::SlashStr);
      MajorVerN=Lx.GetInt(1); Lx.GetPeriod(); MinorVerN=Lx.GetInt(1);
      StatusCd=Lx.GetInt(3);
      ReasonPhrase=Lx.GetRespReasonPhrase();
      Lx.GetCrLf();
      // header fields & values
      while (!Lx.IsCrLf()){
        TStr FldNm=Lx.GetToken(); Lx.GetSpec(THttp::ColonStr);
        TStr FldVal=Lx.GetFldVal();
        Lx.GetCrLf();
        TStr NrFldNm=THttpLx::GetNrStr(FldNm);
        FldNmToValVH.AddDat(NrFldNm).Add(FldVal);
      }
      // separator CrLf
      Lx.GetCrLf();
      // header & body strings
      HdStr=Lx.GetMemSf().GetAsStr();
      Lx.ClrMemSf();
      Lx.GetRest();
      BodyMem=Lx.GetMemSf();
    } else {
      // old fashion format
      MajorVerN=0; MinorVerN=9; StatusCd=200;
      HdStr.Clr();
      Lx.ClrMemSf();
      Lx.GetRest();
      BodyMem=Lx.GetMemSf();
    }
  }
  Ok=true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void THttpRq::ParseHttpRq ( const PSIn SIn)

Definition at line 512 of file http.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), BodyMem, THttpLx::ClrMemSf(), CompleteP, THttpLx::Eof(), FldNmToValH, THttpLx::GetCrLf(), GetFldVal(), THttpLx::GetFldVal(), THttpLx::GetInt(), TStr::GetInt(), THttpLx::GetMemSf(), THttpLx::GetNrStr(), THttpLx::GetPeriod(), THttpLx::GetRest(), THttpLx::GetRqMethod(), THttpLx::GetSpec(), THttpLx::GetToken(), THttpLx::GetUrlStr(), THttpLx::GetWs(), HdStr, heBadUrl, hrmGet, hrmPost, THttpLx::IsCrLf(), IsFldNm(), MajorVerN, Method, MinorVerN, New(), ParseSearch(), SearchStr, Url, and UrlStr.

Referenced by THttpRq().

                                        {
  THttpLx Lx(SIn);
  // initial status
  Ok=false;
  CompleteP=false;
  // request-line
  Method=Lx.GetRqMethod();
  Lx.GetWs();
  //Url=Lx.GetUrl();
  TStr UrlStr=Lx.GetUrlStr();
  Lx.GetWs();
  Lx.GetToken(THttp::HttpStr); Lx.GetSpec(THttp::SlashStr);
  MajorVerN=Lx.GetInt(1); Lx.GetPeriod(); MinorVerN=Lx.GetInt(1);
  Lx.GetCrLf();
  // header fields & values
  while ((!Lx.Eof())&&(!Lx.IsCrLf())){
    TStr FldNm=Lx.GetToken(); Lx.GetSpec(THttp::ColonStr);
    TStr FldVal=Lx.GetFldVal();
    Lx.GetCrLf();
    TStr NrFldNm=THttpLx::GetNrStr(FldNm);
    FldNmToValH.AddDat(NrFldNm, FldVal);
  }
  // separator CrLf
  if (!Lx.IsCrLf()){return;} // to avoid exceptions
  Lx.GetCrLf();
  // header & body strings
  HdStr=Lx.GetMemSf().GetAsStr();
  Lx.ClrMemSf();
  Lx.GetRest();
  BodyMem=Lx.GetMemSf();
  // completeness
  int ContLen=GetFldVal(THttp::ContLenFldNm).GetInt(-1);
  if (ContLen==-1){
    // if not content-len is given we assume http-request is ok
    CompleteP=true;
  } else {
    if (ContLen<=BodyMem.Len()){
      // if we read enough data, we claim completeness
      CompleteP=true;
      BodyMem.Trunc(ContLen);
    } else {
      // if we read not enough data we claim incompleteness
      CompleteP=false;
    }
  }
  // url
  if (CompleteP){
    const TStr LocalBaseUrlStr="http://localhost/";
    Url=TUrl::New(UrlStr, LocalBaseUrlStr);
    if (!Url->IsOk()){
      throw THttpEx(heBadUrl);}
  }
  // search string
  TStr SearchStr;
  if (Method==hrmGet){
    SearchStr=Url->GetSearchStr();
  } else
  if ((Method==hrmPost)&&(
   (!IsFldNm(THttp::ContTypeFldNm))||
   (GetFldVal(THttp::ContTypeFldNm)==THttp::TextHtmlFldVal)||
   (GetFldVal(THttp::ContTypeFldNm)==THttp::AppW3FormFldVal))){
    SearchStr=TStr("?")+BodyMem.GetAsStr();
  }
  ParseSearch(SearchStr);
  // at this point ok=true
  Ok=true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void THttpRq::ParseSearch ( const TStr SearchStr)

Definition at line 461 of file http.cpp.

References TChA::AddCh(), TChA::Clr(), THttpChRet::Eof(), THttpChRet::GetCh(), TCh::GetHex(), heBadSearchStr, TCh::IsHex(), TStrIn::New(), and UrlEnv.

Referenced by ParseHttpRq(), and THttpRq().

                                              {
  PSIn SIn=TStrIn::New(SearchStr);
  THttpChRet ChRet(SIn, heBadSearchStr);
  try {
  // check empty search string
  if (ChRet.Eof()){return;}
  // require '?' at the beginning
  if (ChRet.GetCh()!='?'){
    throw THttpEx(heBadSearchStr);}
  // parse key=val{&...} pairs
  TChA KeyNm; TChA ValStr;
  while (!ChRet.Eof()){
    char Ch; KeyNm.Clr(); ValStr.Clr();
    // key
    while ((Ch=ChRet.GetCh())!='='){
      switch (Ch){
        case '%':{
          char Ch1=ChRet.GetCh();
                  if (!TCh::IsHex(Ch1)) { throw THttpEx(heBadSearchStr); }
                  char Ch2=ChRet.GetCh();
                  if (!TCh::IsHex(Ch2)) { throw THttpEx(heBadSearchStr); }
          KeyNm.AddCh(char(16*TCh::GetHex(Ch1)+TCh::GetHex(Ch2)));} break;
        case '+': KeyNm.AddCh(' '); break;
        case '&': throw THttpEx(heBadSearchStr);
        default: KeyNm.AddCh(Ch);
      }
    }
    // equals
    if (Ch!='='){
      throw THttpEx(heBadSearchStr);}
    // value
    while ((!ChRet.Eof())&&((Ch=ChRet.GetCh())!='&')){
      switch (Ch){
        case '%':{
          char Ch1=ChRet.GetCh();
                  if (!TCh::IsHex(Ch1)) { throw THttpEx(heBadSearchStr); }
          char Ch2=ChRet.GetCh();
                  if (!TCh::IsHex(Ch2)) { throw THttpEx(heBadSearchStr); }
          ValStr.AddCh(char(16*TCh::GetHex(Ch1)+TCh::GetHex(Ch2)));} break;
        case '+': ValStr.AddCh(' '); break;
        case '&': throw THttpEx(heBadSearchStr);
        default: ValStr.AddCh(Ch);
      }
    }
    // save key-value pair
    UrlEnv->AddToKeyVal(KeyNm, ValStr);
    }
  }
  catch (THttpEx){Ok=false;}
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Save ( TSOut )

Definition at line 93 of file http.h.

References Fail.

{Fail;}
void SaveBody ( const PSOut SOut) const

Definition at line 202 of file http.h.

References BodyMem.

                                         {
    BodyMem.SaveMem(SOut);}
void SaveTxt ( const PSOut SOut) const

Definition at line 200 of file http.h.

References BodyMem, HdStr, and TStr::SaveTxt().

                                        {
    HdStr.SaveTxt(SOut); BodyMem.SaveMem(SOut);}

Here is the call graph for this function:

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

Definition at line 739 of file http.cpp.

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

Referenced by LoadTxt(), and New().

                                                                :
  Ok(true), MajorVerN(1), MinorVerN(0), StatusCd(_StatusCd), ReasonPhrase(),
  FldNmToValVH(20), HdStr(), BodyMem(){
  ReasonPhrase=THttp::GetReasonPhrase(StatusCd);
  TChA HdChA;
  // first line
  HdChA+="HTTP/"; HdChA+=TInt::GetStr(MajorVerN); HdChA+=".";
  HdChA+=TInt::GetStr(MinorVerN); HdChA+=' ';
  HdChA+=TInt::GetStr(StatusCd); HdChA+=' ';
  HdChA+=ReasonPhrase;
  HdChA+="\r\n";
  // header fields
  // server
  //AddHdFld(THttp::SrvFldNm, "Tralala", HdChA);
  if (!LocStr.Empty()){
    AddHdFld("Location", LocStr, HdChA);}
  if (!BodySIn.Empty()){
    // content-type
    AddHdFld(THttp::ContTypeFldNm, ContTypeVal, HdChA);
    // accept-ranges
    AddHdFld(THttp::AcceptRangesFldNm, "bytes", HdChA);
    // content-length
    TStr ContLenVal=TInt::GetStr(BodySIn->Len());
    AddHdFld(THttp::ContLenFldNm, ContLenVal, HdChA);
    // cache-control
    if (!CacheCtrlP){
      AddHdFld(THttp::CacheCtrlFldNm, "no-cache", HdChA);}
  }
  // header/body separator
  HdChA+="\r\n";
  // header/body data
  HdStr=HdChA;
  if (!BodySIn.Empty()){
    TMem::LoadMem(BodySIn, BodyMem);}
}

Here is the call graph for this function:

Here is the caller graph for this function:

THttpResp::THttpResp ( const PSIn SIn)

Definition at line 776 of file http.cpp.

References ParseHttpResp().

                                   :
  Ok(false), MajorVerN(0), MinorVerN(0), StatusCd(-1), ReasonPhrase(),
  FldNmToValVH(20), HdStr(), BodyMem(){
  try {
    ParseHttpResp(SIn);
  }
  catch (THttpEx){Ok=false;}
}

Here is the call graph for this function:

THttpResp ( TSIn )

Definition at line 152 of file http.h.

References Fail.

{Fail;}
THttpRq::THttpRq ( const PSIn SIn)

Definition at line 580 of file http.cpp.

References ParseHttpRq().

Referenced by New().

                               :
  Ok(false), MajorVerN(0), MinorVerN(0), Method(hrmUndef),
  FldNmToValH(), UrlEnv(TUrlEnv::New()),
  HdStr(), BodyMem(){
  try {
    ParseHttpRq(SIn);
  }
  catch (THttpEx){Ok=false;}
}

Here is the call graph for this function:

Here is the caller graph for this function:

THttpRq::THttpRq ( const THttpRqMethod _Method,
const PUrl &  _Url,
const TStr ContTypeFldVal,
const TMem _BodyMem,
const int &  FetchId = -1 
)

Definition at line 590 of file http.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Empty(), FldNmToValH, GetMethodNm(), THttpLx::GetNrStr(), TInt::GetStr(), HdStr, HostNm, ParseSearch(), and Url.

                                                                      :
  Ok(false),
  MajorVerN(1), MinorVerN(0),
  Method(_Method),
  Url(_Url),
  FldNmToValH(),
  UrlEnv(TUrlEnv::New()),
  HdStr(), BodyMem(_BodyMem){
  // compose head-http-request
  TChA HdChA;
  if (Url->IsOk()){
    TStr AbsPath=Url->GetPathStr()+Url->GetSearchStr();
    HdChA+=GetMethodNm(); HdChA+=' '; HdChA+=AbsPath; HdChA+=" HTTP/1.0\r\n";
  }
  // add content-type
  if (!ContTypeFldVal.Empty()){
    FldNmToValH.AddDat(THttpLx::GetNrStr(THttp::ContTypeFldNm), ContTypeFldVal);
    HdChA+=THttpLx::GetNrStr(THttp::ContTypeFldNm); HdChA+=": ";
    HdChA+=ContTypeFldVal; HdChA+="\r\n";
  }
  // add host
  if (Url->IsOk()){
    TStr HostNm=Url->GetHostNm();
    FldNmToValH.AddDat(THttpLx::GetNrStr(THttp::HostFldNm), HostNm);
    HdChA+=THttpLx::GetNrStr(THttp::HostFldNm); HdChA+=": ";
    HdChA+=HostNm; HdChA+="\r\n";
    ParseSearch(Url->GetSearchStr());
  }
  // add fetch-id
  if (Url->IsOk()&&(FetchId!=-1)){
    TStr FetchIdStr=TInt::GetStr(FetchId);
    FldNmToValH.AddDat(THttpLx::GetNrStr(THttp::FetchIdFldNm), FetchIdStr);
    HdChA+=THttpLx::GetNrStr(THttp::FetchIdFldNm); HdChA+=": ";
    HdChA+=FetchIdStr; HdChA+="\r\n";
  }
  // finish head-http-request
  if (Url->IsOk()){
    HdChA+="\r\n";
    HdStr=HdChA;
  }
  // set http-request ok
  Ok=true;
}

Here is the call graph for this function:

THttpRq ( TSIn )

Definition at line 91 of file http.h.

References Fail.

{Fail;}
~THttpResp ( )

Definition at line 151 of file http.h.

{}
~THttpRq ( )

Definition at line 90 of file http.h.

{}

Variable Documentation

ClassTP (THttpRq, PHttpRq) private bool CompleteP

Definition at line 64 of file http.h.

Referenced by IsComplete(), and ParseHttpRq().

Definition at line 71 of file http.h.

Referenced by AddFldVal(), GetFldValH(), IsFldNm(), ParseHttpRq(), and THttpRq().

ClassTP (THttpResp, PHttpResp) private int MajorVerN

Definition at line 68 of file http.h.

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

Definition at line 69 of file http.h.

Referenced by GetMethod(), THttpLx::GetRqMethod(), and ParseHttpRq().

ClassTP (THttpResp, PHttpResp) private int MinorVerN

Definition at line 68 of file http.h.

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

Definition at line 135 of file http.h.

Referenced by ParseHttpResp(), and THttpResp().

int StatusCd

Definition at line 134 of file http.h.

Referenced by GetReasonPhrase(), GetStatusCd(), ParseHttpResp(), and THttpResp().

PUrlEnv UrlEnv

Definition at line 72 of file http.h.

Referenced by GetUrlEnv(), New(), and ParseSearch().