Skip to content

Commit

Permalink
Merge pull request #18651 from hrydgard/https-retroachievement-fix
Browse files Browse the repository at this point in the history
HTTPS through naett: Get the body of the response even if code isn't 200
  • Loading branch information
hrydgard committed Dec 31, 2023
2 parents 5a7db8a + 78de59a commit eabcd5d
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 eabcd5d

Please sign in to comment.