aboutsummaryrefslogtreecommitdiff
path: root/src/curl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/curl.cpp')
-rw-r--r--src/curl.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/curl.cpp b/src/curl.cpp
index f39cab8..e141e78 100644
--- a/src/curl.cpp
+++ b/src/curl.cpp
@@ -70,10 +70,24 @@ namespace sibs
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, file);
printf("Downloading from url: %s\n", url);
CURLcode curlResponse = curl_easy_perform(curl_handle);
+
+ long httpCode = 0;
+ curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl_handle);
fclose(file);
- if(curlResponse != CURLE_OK)
+ if(httpCode == 200 && curlResponse == CURLE_OK)
+ return Result<bool>::Ok(true);
+
+ if(httpCode != 200)
+ {
+ string errMsg = "Failed to download file from url: ";
+ errMsg += url;
+ errMsg += "\nReason: Expected http response code 200 (OK), got: ";
+ errMsg += to_string(httpCode);
+ return Result<bool>::Err(errMsg);
+ }
+ else
{
string errMsg = "Failed to download file from url: ";
errMsg += url;
@@ -81,7 +95,5 @@ namespace sibs
errMsg += curl_easy_strerror(curlResponse);
return Result<bool>::Err(errMsg);
}
-
- return Result<bool>::Ok(true);
}
} \ No newline at end of file