mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-09 12:54:23 +01:00
Differentiate between success (full or partial), not-found, and failure.
* keyserver/gpgkeys_hkp.c (get_key): Use curl_easy_setinfo to get the HTTP status code so we can tell the difference between a successful retrieval, a partial retrieval, a not-found, or a server failed.
This commit is contained in:
parent
ca0b94d4d4
commit
6f0ec6ab48
@ -1,6 +1,6 @@
|
|||||||
/* gpgkeys_hkp.c - talk to an HKP keyserver
|
/* gpgkeys_hkp.c - talk to an HKP keyserver
|
||||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||||
* 2009, 2012 Free Software Foundation, Inc.
|
* 2009, 2012, 2013 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -312,15 +312,49 @@ get_key(char *getkey)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
long status = 0;
|
||||||
|
|
||||||
curl_writer_finalize(&ctx);
|
curl_writer_finalize(&ctx);
|
||||||
if(!ctx.flags.done)
|
|
||||||
|
curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &status);
|
||||||
|
|
||||||
|
if (opt->verbose > 2)
|
||||||
|
fprintf (console, "gpgkeys: HTTP response code is %ld\n", status);
|
||||||
|
|
||||||
|
if (status == 200)
|
||||||
{
|
{
|
||||||
fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey);
|
if (!ctx.flags.done)
|
||||||
fprintf(output,"\nKEY 0x%s FAILED %d\n",
|
{
|
||||||
getkey,KEYSERVER_KEY_NOT_FOUND);
|
if (ctx.flags.begun)
|
||||||
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s partially retrieved"
|
||||||
|
" (probably corrupt)\n", getkey);
|
||||||
|
fprintf (output, "\nKEY 0x%s FAILED %d\n",
|
||||||
|
getkey, KEYSERVER_KEY_INCOMPLETE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s can't be retrieved\n",
|
||||||
|
getkey);
|
||||||
|
fprintf (output, "\nKEY 0x%s FAILED %d\n",
|
||||||
|
getkey, KEYSERVER_GENERAL_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf (output, "\nKEY 0x%s END\n", getkey);
|
||||||
|
}
|
||||||
|
else if (status == 404)
|
||||||
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s not found on keyserver\n", getkey);
|
||||||
|
fprintf (output, "\nKEY 0x%s FAILED %d\n",
|
||||||
|
getkey, KEYSERVER_KEY_NOT_FOUND);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(output,"\nKEY 0x%s END\n",getkey);
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s can't be retrieved\n", getkey);
|
||||||
|
fprintf (output, "\nKEY 0x%s FAILED %d\n",
|
||||||
|
getkey, KEYSERVER_GENERAL_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return KEYSERVER_OK;
|
return KEYSERVER_OK;
|
||||||
@ -383,16 +417,47 @@ get_name(const char *getkey)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
long status = 0;
|
||||||
|
|
||||||
curl_writer_finalize(&ctx);
|
curl_writer_finalize(&ctx);
|
||||||
if(!ctx.flags.done)
|
|
||||||
|
curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &status);
|
||||||
|
|
||||||
|
if (opt->verbose > 2)
|
||||||
|
fprintf (console, "gpgkeys: HTTP response code is %ld\n", status);
|
||||||
|
|
||||||
|
if (status == 200)
|
||||||
{
|
{
|
||||||
fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey);
|
if (!ctx.flags.done)
|
||||||
ret=KEYSERVER_KEY_NOT_FOUND;
|
{
|
||||||
|
if (ctx.flags.begun)
|
||||||
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s partially retrieved"
|
||||||
|
" (probably corrupt)\n", getkey);
|
||||||
|
ret = KEYSERVER_KEY_INCOMPLETE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s can't be retrieved\n",
|
||||||
|
getkey);
|
||||||
|
ret = KEYSERVER_GENERAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (output, "\nNAME %s END\n", getkey);
|
||||||
|
ret = KEYSERVER_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (status == 404)
|
||||||
|
{
|
||||||
|
fprintf (console, "gpgkeys: key %s not found on keyserver\n", getkey);
|
||||||
|
ret = KEYSERVER_KEY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(output,"\nNAME %s END\n",getkey);
|
fprintf (console, "gpgkeys: key %s can't be retrieved\n", getkey);
|
||||||
ret=KEYSERVER_OK;
|
ret = KEYSERVER_GENERAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user