Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PHTTPClient::GetDocument ( const PURL url,
PMIMEInfo &  outMIME,
PMIMEInfo &  replyMIME,
BOOL  persist = TRUE 
)

Get the document specified by the URL.

Returns:
TRUE if document is being transferred.
Parameters:
url  Universal Resource Locator for document.
outMIME  MIME info in request
replyMIME  MIME info in response
persist  if TRUE, enable HTTP persistence

Definition at line 519 of file httpclnt.cxx.

References PURL::AsString(), ExecuteCommand(), PString::IsEmpty(), PHTTP::MovedPermanently, PHTTP::MovedTemporarily, ReadContentBody(), and PHTTP::RequestOK.

Referenced by GetTextDocument().

{
  int count = 0;
  static const char locationTag[] = "Location";
  PURL url = _url;
  for (;;) {
    PMIMEInfo outMIME = _outMIME;
    replyMIME.RemoveAll();
    PString u = url.AsString();
    int code = ExecuteCommand(GET, url, outMIME, PString(), replyMIME, persist);
    switch (code) {
      case RequestOK:
        return TRUE;
      case MovedPermanently:
      case MovedTemporarily:
        {
          if (count > 10)
            return FALSE;
          PString str = replyMIME(locationTag);
          if (str.IsEmpty())
            return FALSE;
          PString doc;
          if (!ReadContentBody(replyMIME, doc))
            return FALSE;
          url = str;
          count++;
        }
        break;
      default:
        return FALSE;
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index