Skip to content

Commit

Permalink
HTTPS through naett: Get the body of the response even if code isn't …
Browse files Browse the repository at this point in the history
…200.

This is required for rcheevos to parse errors properly - it ignores the
error code and parses it out of the body instead.
  • Loading branch information
hrydgard committed Dec 30, 2023
1 parent de0d82d commit 78de59a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Common/Net/HTTPNaettRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ bool HTTPSRequest::Done() {

// -1000 is a code specified by us to represent cancellation, that is unlikely to ever collide with naett error codes.
resultCode_ = IsCancelled() ? -1000 : naettGetStatus(res_);
int bodyLength;
const void *body = naettGetBody(res_, &bodyLength);
char *dest = buffer_.Append(bodyLength);
memcpy(dest, body, bodyLength);
if (resultCode_ < 0) {
// It's a naett error. Translate and handle.
switch (resultCode_) {
Expand All @@ -100,12 +104,8 @@ bool HTTPSRequest::Done() {
break;
}
failed_ = true;
progress_.Update(0, 0, true);
progress_.Update(bodyLength, bodyLength, true);
} else if (resultCode_ == 200) {
int bodyLength;
const void *body = naettGetBody(res_, &bodyLength);
char *dest = buffer_.Append(bodyLength);
memcpy(dest, body, bodyLength);
if (!outfile_.empty() && !buffer_.FlushToFile(outfile_)) {
ERROR_LOG(IO, "Failed writing download to '%s'", outfile_.c_str());
}
Expand Down

0 comments on commit 78de59a

Please sign in to comment.