Skip to content

Commit

Permalink
try http if server returns non-200 status
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Dec 16, 2024
1 parent d745997 commit 357b78d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/libgamestream/src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,12 @@ static int load_server_status(GS_CLIENT hnd, PSERVER_DATA server) {
ret = GS_OUT_OF_MEMORY;
goto cleanup;
}
if (http_request(hnd->http, url, data) != GS_OK) {
ret = GS_IO_ERROR;
if ((ret = http_request(hnd->http, url, data)) != GS_OK) {
if (i == 0 && ret == GS_FAILED) {
ret = GS_ERROR;
} else {
ret = GS_IO_ERROR;
}
goto cleanup;
}

Expand Down
7 changes: 6 additions & 1 deletion core/libgamestream/src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ int http_request(HTTP *http, char *url, HTTP_DATA *data) {
int ret = GS_FAILED;
CURLcode res = curl_easy_perform(curl);

if (res != CURLE_OK) {
if (res == CURLE_HTTP_RETURNED_ERROR) {
int http_status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status);
commons_log_warn("GameStream", "Request %p error HTTP %d", data, http_status);
goto finish;
} else if (res != CURLE_OK) {
const char *errmsg = curl_easy_strerror(res);
ret = gs_set_error(GS_IO_ERROR, "cURL error: %s", errmsg);
commons_log_debug("GameStream", "Request %p error %d: %s", data, ret, errmsg);
Expand Down

0 comments on commit 357b78d

Please sign in to comment.