do {
// Data was read OK. Look through the data that we've read so far, to see if it contains <CR><LF><CR><LF>.
// (If not, wait for more data to arrive.)
Boolean endOfHeaders = False;
char const *ptr = fResponseBuffer;

if(strcmp(foundRequest->commandName(), "GET") == 0) {
// Note: If a HTTP "GET" command (for RTSP-over-HTTP tunneling) returns "401 Unauthorized", then we resend it
// (with an "Authorization:" header), just as we would for a RTSP command. However, we do so using a new TCP connection,
// because some servers close the original connection after returning the "401 Unauthorized".
resetTCPSockets(); // forces the opening of a new connection for the resent command
}
} else if(responseCode == 301 || responseCode == 302) { // redirection
resetTCPSockets(); // because we need to connect somewhere else next
needToResendCommand = True;
}

// If we have a handler function for this response, call it.
// But first, reset our response buffer, in case the handler goes to the event loop, and we end up getting called recursively:
if(numExtraBytesAfterResponse > 0) {
// An unusual case; usually due to having received pipelined responses. Move the extra bytes to the front of the buffer:
char *responseEnd = &fResponseBuffer[fResponseBytesAlreadySeen - numExtraBytesAfterResponse];

// But first: A hack to save a copy of the response 'body', in case it's needed below for "resultString":
numBodyBytes -= numExtraBytesAfterResponse;