mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
BACKENDS: NETWORKING: Make SessionRequest correctly process HTTP error codes
This commit is contained in:
parent
a89cb7f85e
commit
768cac42f9
@ -63,8 +63,8 @@ RequestState Request::state() const { return _state; }
|
||||
|
||||
Common::String Request::date() const { return ""; }
|
||||
|
||||
void Request::finishError(ErrorResponse error) {
|
||||
_state = FINISHED;
|
||||
void Request::finishError(ErrorResponse error, RequestState state) {
|
||||
_state = state;
|
||||
if (_errorCallback)
|
||||
(*_errorCallback)(error);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ protected:
|
||||
uint32 _retryInSeconds;
|
||||
|
||||
/** Sets FINISHED state and calls the _errorCallback with given error. */
|
||||
virtual void finishError(ErrorResponse error);
|
||||
virtual void finishError(ErrorResponse error, RequestState state = FINISHED);
|
||||
|
||||
/** Sets FINISHED state. Implementations might extend it if needed. */
|
||||
virtual void finishSuccess();
|
||||
|
@ -75,10 +75,10 @@ char *SessionRequest::getPreparedContents() {
|
||||
return (char *)result;
|
||||
}
|
||||
|
||||
void SessionRequest::finishError(ErrorResponse error) {
|
||||
void SessionRequest::finishError(ErrorResponse error, RequestState state) {
|
||||
_complete = true;
|
||||
_success = false;
|
||||
CurlRequest::finishError(error);
|
||||
CurlRequest::finishError(error, PAUSED);
|
||||
}
|
||||
|
||||
void SessionRequest::finishSuccess() {
|
||||
@ -120,6 +120,12 @@ void SessionRequest::handle() {
|
||||
if (!_stream) _stream = makeStream();
|
||||
|
||||
if (_stream) {
|
||||
if (_stream->httpResponseCode() != 200 && _stream->httpResponseCode() != 0) {
|
||||
warning("SessionRequest: HTTP response code is not 200 OK (it's %ld)", _stream->httpResponseCode());
|
||||
ErrorResponse error(this, false, true, "HTTP response code is not 200 OK", _stream->httpResponseCode());
|
||||
finishError(error);
|
||||
return;
|
||||
}
|
||||
uint32 readBytes = _stream->read(_buffer, CURL_SESSION_REQUEST_BUFFER_SIZE);
|
||||
if (readBytes != 0)
|
||||
if (_contentsStream.write(_buffer, readBytes) != readBytes)
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
/** Prepares raw bytes from _contentsStream. */
|
||||
char *getPreparedContents();
|
||||
|
||||
virtual void finishError(ErrorResponse error);
|
||||
virtual void finishError(ErrorResponse error, RequestState state = PAUSED);
|
||||
virtual void finishSuccess();
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user