[maemo-commits] [maemo-commits] r14950 - projects/haf/trunk/apt-https
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Dec 12 18:31:42 EET 2007
- Previous message: [maemo-commits] r14949 - in projects/haf/trunk/apt-https: . debian
- Next message: [maemo-commits] r14951 - in projects/haf/trunk/apt-https: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2007-12-12 18:31:41 +0200 (Wed, 12 Dec 2007)
New Revision: 14950
Modified:
projects/haf/trunk/apt-https/maemo-mini-curl.c
Log:
* maemo-mini-curl.c (fetch): Check the response code and fail if
it is not 200.
Modified: projects/haf/trunk/apt-https/maemo-mini-curl.c
===================================================================
--- projects/haf/trunk/apt-https/maemo-mini-curl.c 2007-12-12 16:31:29 UTC (rev 14949)
+++ projects/haf/trunk/apt-https/maemo-mini-curl.c 2007-12-12 16:31:41 UTC (rev 14950)
@@ -126,7 +126,8 @@
int
fetch (const char *url, const char *dst)
{
- CURLcode res;
+ int success;
+ long response;
char errorbuffer[CURL_ERROR_SIZE];
FILE *f;
@@ -148,21 +149,29 @@
curl_easy_setopt (curl, CURLOPT_SSL_CTX_FUNCTION, my_sslctxfun);
- res = curl_easy_perform (curl);
+ success = 0;
+ if (curl_easy_perform (curl) == 0
+ && curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &response) == 0)
+ {
+ success = (response == 200);
+ snprintf (errorbuffer, CURL_ERROR_SIZE, "%ld", response);
+ }
if (fclose (f) == EOF)
{
perror (dst);
+ unlink (dst);
return 0;
}
-
- if (res)
+
+ if (!success)
{
fprintf (stderr, "%s\n", errorbuffer);
unlink (dst);
return 0;
}
+
return 1;
}
- Previous message: [maemo-commits] r14949 - in projects/haf/trunk/apt-https: . debian
- Next message: [maemo-commits] r14951 - in projects/haf/trunk/apt-https: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
