1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

dirmngr: Improve error codes returned from http fetching.

* dirmngr/ks-engine-http.c (ks_http_fetch): Return better error codes.
* dirmngr/ks-engine-hkp.c (send_request): Ditto.
* dirmngr/t-http.c (main): New option --try-proxy.
This commit is contained in:
Werner Koch 2023-09-19 16:14:01 +02:00
parent 1e120f5a8d
commit 668deeded9
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 20 additions and 14 deletions

View File

@ -1340,18 +1340,17 @@ send_request (ctrl_t ctrl, const char *request, const char *hostportstr,
}
goto once_more;
case 501:
err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
goto leave;
case 413: /* Payload too large */
err = gpg_error (GPG_ERR_TOO_LARGE);
goto leave;
default:
log_error (_("error accessing '%s': http status %u\n"),
request, http_get_status_code (http));
err = gpg_error (GPG_ERR_NO_DATA);
switch (http_get_status_code (http))
{
case 401: err = gpg_error (GPG_ERR_NO_AUTH); break;
case 407: err = gpg_error (GPG_ERR_BAD_AUTH); break;
case 413: err = gpg_error (GPG_ERR_TOO_LARGE); break;
case 501: err = gpg_error (GPG_ERR_NOT_IMPLEMENTED); break;
default: err = gpg_error (GPG_ERR_NO_DATA); break;
}
goto leave;
}

View File

@ -193,14 +193,16 @@ ks_http_fetch (ctrl_t ctrl, const char *url, unsigned int flags,
}
goto once_more;
case 413: /* Payload too large */
err = gpg_error (GPG_ERR_TOO_LARGE);
goto leave;
default:
log_error (_("error accessing '%s': http status %u\n"),
url, http_get_status_code (http));
err = gpg_error (GPG_ERR_NO_DATA);
switch (http_get_status_code (http))
{
case 401: err = gpg_error (GPG_ERR_NO_AUTH); break;
case 407: err = gpg_error (GPG_ERR_BAD_AUTH); break;
case 413: err = gpg_error (GPG_ERR_TOO_LARGE); break;
default: err = gpg_error (GPG_ERR_NO_DATA); break;
}
goto leave;
}

View File

@ -288,6 +288,11 @@ main (int argc, char **argv)
my_http_flags |= HTTP_FLAG_FORCE_TOR;
argc--; argv++;
}
else if (!strcmp (*argv, "--try-proxy"))
{
my_http_flags |= HTTP_FLAG_TRY_PROXY;
argc--; argv++;
}
else if (!strcmp (*argv, "--no-out"))
{
no_out = 1;