Hi Peter,
You could also have a look at RFC 2616 Section 10.4 Client Error 4xx about the different HTTP 400 error codes. We should think what we should do in case of an HTTP server error response - maybe think of a way to report HTTP errors and tracker errors (ones reported in the bencoded dictionary) in an uniform way to the user code. Maybe plain strings (”HTTP server responded: 404 Not Found”, or “Tracker responded: Unknown info_hash”) and a single status notification, or plain strings with two status notifications (e.g. trackerRequestFailedOnHttpError (”404 NotFound”) and trackerRequestFaildOnTrackerError (”Unknown info_hash”)?
I’ve been thinking whether we should also check trackerResponse.failureReason() in the TrackerRequestSession and call something like trackerRequestFaildOnTrackerError(), or check only HTTP errors - there is no problem with checking HTTP errors. However, I’m not sure where to put the response check and the failure call. Now I’ve this code to handle response bodies:
TrackerResponse trackerResponse;
bool parsedOk = TrackerResponseParser::parseAndLoadTrackerResponse (
rawResponseBody, trackerResponse);
if (parsedOk) {
sessionStatus_.trackerRequestSessionResponseRecieved (trackerResponse);
sessionState_ = ResponseBodyRecieved;
}
else {
httpRequestSession_.close();
close();
}
My questions are:
1. Should I check there also tracker errors via trackerResponse.failureReason()? If so, I’d need to modify testing scenario (scenarioRecieveResponse()) to differentiate between “response was[n’t] parsed correctly” and “response has[n’t] errors”.
2. Assuming that the answer to the previous question is “yes”, should I put the trackerRequestFaildOnTrackerError() call before the trackerRequestSessionResponseRecieved() call or after it?
3. Since there is nothing to do after a response is recieved, should I also close session if a valid response (without errors) is get or only if there was some error?
4. As for checking HTTP request success, should I consider something else than status code == 200 as a success?
Thanks for reply,
Petr
