diff options
author | Justus Winter <[email protected]> | 2015-12-04 11:32:20 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2015-12-04 12:02:56 +0000 |
commit | 6d64ef869dfbcb7aaa802b80ed648393147e40d8 (patch) | |
tree | 043dc98eb289f08a36b227ca5bcdd4942c07c960 /dirmngr/ks-action.c | |
parent | dirmngr: Really search all keyservers for patterns. (diff) | |
download | gnupg-6d64ef869dfbcb7aaa802b80ed648393147e40d8.tar.gz gnupg-6d64ef869dfbcb7aaa802b80ed648393147e40d8.zip |
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 <[email protected]>
Diffstat (limited to 'dirmngr/ks-action.c')
-rw-r--r-- | dirmngr/ks-action.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/dirmngr/ks-action.c b/dirmngr/ks-action.c index 285167a17..1da91cccf 100644 --- a/dirmngr/ks-action.c +++ b/dirmngr/ks-action.c @@ -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; |