Merge pull request #898 from joemfb/pill-s-err

checks HTTP response code when fetching pill
This commit is contained in:
Ted Blackman 2017-11-29 17:00:40 -08:00 committed by GitHub
commit 9a4d7fb2f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1619,6 +1619,7 @@ _boot_home(c3_c *dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c)
CURLcode result;
FILE *file;
c3_c pil_c[2048];
long cod_l;
/* use arvo git hash and branch for pill url unless overridden */
if ( NULL == url_c ) {
@ -1639,14 +1640,21 @@ _boot_home(c3_c *dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c)
curl_easy_setopt(curl, CURLOPT_URL, url_c);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l);
fclose(file);
if ( result != CURLE_OK ) {
if ( CURLE_OK != result ) {
fprintf(stderr, "failed to fetch %s: %s\n",
url_c, curl_easy_strerror(result));
fprintf(stderr,
"please fetch it manually and specify the location with -B\n");
exit(1);
}
if ( 300 <= cod_l ) {
fprintf(stderr, "error fetching %s: HTTP %ld\n", url_c, cod_l);
fprintf(stderr,
"please fetch it manually and specify the location with -B\n");
exit(1);
}
curl_easy_cleanup(curl);
}
}