From 06a2fe398459385de6910513e56abfe4a17a2aa0 Mon Sep 17 00:00:00 2001 From: Ningyuan Li Date: Mon, 16 Dec 2024 10:41:54 +0900 Subject: [PATCH] try http if server returns non-200 status --- core/libgamestream/src/client.c | 8 ++++++-- core/libgamestream/src/http.c | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/libgamestream/src/client.c b/core/libgamestream/src/client.c index 4fdd3519..4483cfed 100644 --- a/core/libgamestream/src/client.c +++ b/core/libgamestream/src/client.c @@ -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; } diff --git a/core/libgamestream/src/http.c b/core/libgamestream/src/http.c index 1e45fce1..7f7f0ec0 100644 --- a/core/libgamestream/src/http.c +++ b/core/libgamestream/src/http.c @@ -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);