BACKENDS: NETWORKING: Make SessionRequest correctly process HTTP error codes
This commit is contained in:
parent
a89cb7f85e
commit
768cac42f9
4 changed files with 12 additions and 6 deletions
|
@ -63,8 +63,8 @@ RequestState Request::state() const { return _state; }
|
||||||
|
|
||||||
Common::String Request::date() const { return ""; }
|
Common::String Request::date() const { return ""; }
|
||||||
|
|
||||||
void Request::finishError(ErrorResponse error) {
|
void Request::finishError(ErrorResponse error, RequestState state) {
|
||||||
_state = FINISHED;
|
_state = state;
|
||||||
if (_errorCallback)
|
if (_errorCallback)
|
||||||
(*_errorCallback)(error);
|
(*_errorCallback)(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ protected:
|
||||||
uint32 _retryInSeconds;
|
uint32 _retryInSeconds;
|
||||||
|
|
||||||
/** Sets FINISHED state and calls the _errorCallback with given error. */
|
/** 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. */
|
/** Sets FINISHED state. Implementations might extend it if needed. */
|
||||||
virtual void finishSuccess();
|
virtual void finishSuccess();
|
||||||
|
|
|
@ -75,10 +75,10 @@ char *SessionRequest::getPreparedContents() {
|
||||||
return (char *)result;
|
return (char *)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionRequest::finishError(ErrorResponse error) {
|
void SessionRequest::finishError(ErrorResponse error, RequestState state) {
|
||||||
_complete = true;
|
_complete = true;
|
||||||
_success = false;
|
_success = false;
|
||||||
CurlRequest::finishError(error);
|
CurlRequest::finishError(error, PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionRequest::finishSuccess() {
|
void SessionRequest::finishSuccess() {
|
||||||
|
@ -120,6 +120,12 @@ void SessionRequest::handle() {
|
||||||
if (!_stream) _stream = makeStream();
|
if (!_stream) _stream = makeStream();
|
||||||
|
|
||||||
if (_stream) {
|
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);
|
uint32 readBytes = _stream->read(_buffer, CURL_SESSION_REQUEST_BUFFER_SIZE);
|
||||||
if (readBytes != 0)
|
if (readBytes != 0)
|
||||||
if (_contentsStream.write(_buffer, readBytes) != readBytes)
|
if (_contentsStream.write(_buffer, readBytes) != readBytes)
|
||||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
/** Prepares raw bytes from _contentsStream. */
|
/** Prepares raw bytes from _contentsStream. */
|
||||||
char *getPreparedContents();
|
char *getPreparedContents();
|
||||||
|
|
||||||
virtual void finishError(ErrorResponse error);
|
virtual void finishError(ErrorResponse error, RequestState state = PAUSED);
|
||||||
virtual void finishSuccess();
|
virtual void finishSuccess();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue