Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Server HTTP Status Code #485

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading