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

BOOL PInternetProtocol::ReadResponse (  ) [virtual, inherited]

Read a response code followed by a text string describing the response to a command. The form of the response is to have the code string, then the info string.

The response may have multiple lines in it. A '-' character separates the code from the text on all lines but the last where a ' ' character is used. The info parameter will have placed in it all of the response lines separated by a single '
' character.

The first form places the response code and info into the protected member variables lastResponseCode and lastResponseInfo.

This function is typically used by client forms of the socket.

Returns:
TRUE if the response was completely read without a socket error.

Definition at line 597 of file inetprot.cxx.

References PChannel::GetErrorCode(), PIndirectChannel::GetErrorText(), PChannel::LastReadError, PString::Left(), PString::Mid(), PInternetProtocol::ParseResponse(), PChannel::ProtocolFailure, PInternetProtocol::ReadLine(), and PChannel::SetErrorValues().

Referenced by PSMTPClient::EndMessage(), PInternetProtocol::ExecuteCommand(), PFTPClient::GetDirectoryNames(), PFTPClient::GetFileStatus(), PPOP3Client::LogIn(), PPOP3Client::OnOpen(), PSMTPClient::OnOpen(), PFTPClient::OnOpen(), PInternetProtocol::ReadResponse(), and PHTTPClient::ReadResponse().

{
  PString line;
  if (!ReadLine(line)) {
    lastResponseCode = -1;
    if (GetErrorCode(LastReadError) != NoError)
      lastResponseInfo = GetErrorText(LastReadError);
    else {
      lastResponseInfo = "Remote shutdown";
      SetErrorValues(ProtocolFailure, 0, LastReadError);
    }
    return FALSE;
  }

  PINDEX continuePos = ParseResponse(line);
  if (continuePos == 0)
    return TRUE;

  PString prefix = line.Left(continuePos);
  char continueChar = line[continuePos];
  while (line[continuePos] == continueChar ||
         (!isdigit(line[0]) && strncmp(line, prefix, continuePos) != 0)) {
    lastResponseInfo += '\n';
    if (!ReadLine(line)) {
      if (GetErrorCode(LastReadError) != NoError)
        lastResponseInfo += GetErrorText(LastReadError);
      else
        SetErrorValues(ProtocolFailure, 0, LastReadError);
      return FALSE;
    }
    if (line.Left(continuePos) == prefix)
      lastResponseInfo += line.Mid(continuePos+1);
    else
      lastResponseInfo += line;
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index