diff options
author | Werner Koch <[email protected]> | 2023-10-02 10:53:41 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-10-02 11:05:49 +0000 |
commit | 53bdb7440cbe18f73548169528167190d70998ed (patch) | |
tree | d945ed7ba3bad4d72f2140654dc89210e0ea3792 /dirmngr/http.c | |
parent | common: Add new function b64decode. (diff) | |
download | gnupg-53bdb7440cbe18f73548169528167190d70998ed.tar.gz gnupg-53bdb7440cbe18f73548169528167190d70998ed.zip |
dirmngr: Extended the http_get_header function.
* dirmngr/http.c (send_request): Add arg 'skip'. Adjust all callers.
--
GnuPG-bug-id: 6719
Diffstat (limited to 'dirmngr/http.c')
-rw-r--r-- | dirmngr/http.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/dirmngr/http.c b/dirmngr/http.c index a44b0d244..32e6a6cb8 100644 --- a/dirmngr/http.c +++ b/dirmngr/http.c @@ -2845,18 +2845,27 @@ store_header (http_t hd, char *line) /* Return the header NAME from the last response. The returned value - is valid as along as HD has not been closed and no other request - has been send. If the header was not found, NULL is returned. NAME - must be canonicalized, that is the first letter of each dash - delimited part must be uppercase and all other letters lowercase. */ + * is valid as along as HD has not been closed and no other request + * has been send. If the header was not found, NULL is returned. NAME + * must be canonicalized, that is the first letter of each dash + * delimited part must be uppercase and all other letters lowercase. + * SKIP gives the number of entries of the requested NAME to skip + * before returning; this can be used to enumerate headers with the + * same name (see store_header). +*/ const char * -http_get_header (http_t hd, const char *name) +http_get_header (http_t hd, const char *name, unsigned int skip) { header_t h; for (h=hd->headers; h; h = h->next) - if ( !strcmp (h->name, name) ) - return h->value; + if (!strcmp (h->name, name)) + { + if (skip) + skip--; + else + return h->value; + } return NULL; } @@ -2979,7 +2988,7 @@ parse_response (http_t hd) cookie->content_length_valid = 0; if (!(hd->flags & HTTP_FLAG_IGNORE_CL)) { - s = http_get_header (hd, "Content-Length"); + s = http_get_header (hd, "Content-Length", 0); if (s) { cookie->content_length_valid = 1; |