Skip to content

Commit

Permalink
Check for error code in gghttplib_process_request
Browse files Browse the repository at this point in the history
  • Loading branch information
AniruddhaKanhere committed Nov 11, 2024
1 parent b85ca29 commit 644a69d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ggl-http/src/gghttp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,26 @@ GglError gghttplib_process_request(

curl_error = curl_easy_perform(curl_data->curl);
if (curl_error != CURLE_OK) {
GGL_LOGE(
"curl_easy_perform() failed: %s", curl_easy_strerror(curl_error)
);
return translate_curl_code(curl_error);
}

long http_status_code = 0;
curl_easy_getinfo(curl_data->curl, CURLINFO_HTTP_CODE, &http_status_code);
GGL_LOGI("HTTP code: %ld", http_status_code);
curl_error = curl_easy_getinfo(
curl_data->curl, CURLINFO_HTTP_CODE, &http_status_code
);

if (curl_error != CURLE_OK) {
GGL_LOGE(
"curl_easy_perform() failed: %s", curl_easy_strerror(curl_error)
"curl_easy_getinfo() failed: %s", curl_easy_strerror(curl_error)
);
return translate_curl_code(curl_error);
}

GGL_LOGI("HTTP code: %ld", http_status_code);

// TODO: propagate HTTP code up for deployment failure root causing
if (http_status_code < 200 || http_status_code > 299) {
return GGL_ERR_FAILURE;
Expand Down

0 comments on commit 644a69d

Please sign in to comment.