fix: dont print body on stdout
This commit is contained in:
parent
b8243e3ee9
commit
48d177965e
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-05-09 23:17+0300\n"
|
||||
"POT-Creation-Date: 2024-05-09 23:28+0300\n"
|
||||
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
||||
"Last-Translator: <ngn@ngn.tf>\n"
|
||||
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
||||
@ -254,26 +254,30 @@ msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:44
|
||||
msgid "Failed to open /dev/null"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:51
|
||||
msgid "Failed to init curl"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:55
|
||||
#: src/url.c:63
|
||||
msgid "Request failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:62
|
||||
#: src/url.c:70
|
||||
msgid "Failed to get the response code"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:68
|
||||
#: src/url.c:76
|
||||
msgid "Response is not a redirect"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:75
|
||||
#: src/url.c:83
|
||||
msgid "Failed to get the location header"
|
||||
msgstr ""
|
||||
|
||||
#: src/url.c:81
|
||||
#: src/url.c:89
|
||||
msgid "Invalid location header"
|
||||
msgstr ""
|
||||
|
||||
|
@ -19,12 +19,13 @@ enum ErrorCodes {
|
||||
|
||||
UrlCurlFail = 940,
|
||||
UrlReqFail = 939,
|
||||
UrlNullFail = 938,
|
||||
|
||||
UrlReqCodeFail = 938,
|
||||
UrlReqBadCode = 937,
|
||||
UrlReqCodeFail = 937,
|
||||
UrlReqBadCode = 936,
|
||||
|
||||
UrlLocationFail = 936,
|
||||
UrlLocationBad = 935
|
||||
UrlLocationFail = 935,
|
||||
UrlLocationBad = 934
|
||||
};
|
||||
|
||||
extern int errno;
|
||||
|
14
src/url.c
14
src/url.c
@ -36,19 +36,27 @@ char *url_complete(char *name) {
|
||||
char url[strlen(name) + strlen(HUB_URL) + 1];
|
||||
sprintf(url, "%s/%s", HUB_URL, name);
|
||||
|
||||
FILE *devnull = fopen("/dev/null", "w");
|
||||
char *location = NULL;
|
||||
long code = 0;
|
||||
|
||||
if (NULL == devnull) {
|
||||
error_set(_("Failed to open /dev/null"));
|
||||
errno = UrlNullFail;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
if (NULL == curl) {
|
||||
error_set(_("Failed to init curl"));
|
||||
errno = UrlCurlFail;
|
||||
return NULL;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl/mp");
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, devnull);
|
||||
CURLcode res = curl_easy_perform(curl);
|
||||
|
||||
if (res != CURLE_OK) {
|
||||
@ -86,7 +94,9 @@ char *url_complete(char *name) {
|
||||
location = strdup(location);
|
||||
|
||||
CLEANUP:
|
||||
curl_easy_cleanup(curl);
|
||||
fclose(devnull);
|
||||
if (NULL != curl)
|
||||
curl_easy_cleanup(curl);
|
||||
return location;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user