mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
dirmngr: Stricter handling of http error codes.
* dirmngr/ks-action.c (ks_action_search): Only retry if the keyserver responded with a '404 Not Found'. * dirmngr/ks-engine-hkp.c (send_request): Return http status code. (ks_hkp_search): Likewise. (ks_hkp_{get,put}): Adapt call to 'send_request'. * dirmngr/ks-engine.h (ks_hkp_search): Update prototype. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
6ac57a482f
commit
6d64ef869d
3 changed files with 21 additions and 13 deletions
|
@ -156,13 +156,13 @@ ks_action_search (ctrl_t ctrl, uri_item_t keyservers,
|
|||
parallel and merge them. We also need to decide what to do with
|
||||
errors - it might not be the best idea to ignore an error from
|
||||
one server and silently continue with another server. For now we
|
||||
stop at the first error, unless it is GPG_ERR_NO_DATA, in which
|
||||
case we try the next server. Unfortunately, 'send_requests'
|
||||
broadly maps all kinds of http errors to GPG_ERR_NO_DATA. */
|
||||
stop at the first error, unless the server responds with '404 Not
|
||||
Found', in which case we try the next server. */
|
||||
for (uri = keyservers; !err && uri; uri = uri->next)
|
||||
{
|
||||
int is_http = uri->parsed_uri->is_http;
|
||||
int is_ldap = 0;
|
||||
unsigned int http_status;
|
||||
#if USE_LDAP
|
||||
is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0
|
||||
|| strcmp (uri->parsed_uri->scheme, "ldaps") == 0
|
||||
|
@ -177,10 +177,12 @@ ks_action_search (ctrl_t ctrl, uri_item_t keyservers,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
err = ks_hkp_search (ctrl, uri->parsed_uri, patterns->d, &infp);
|
||||
err = ks_hkp_search (ctrl, uri->parsed_uri, patterns->d,
|
||||
&infp, &http_status);
|
||||
}
|
||||
|
||||
if (err == gpg_error (GPG_ERR_NO_DATA))
|
||||
if (err == gpg_error (GPG_ERR_NO_DATA)
|
||||
&& http_status == 404 /* not found */)
|
||||
{
|
||||
/* No record found. Clear error and try next server. */
|
||||
err = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue