From eeec1fcf0dad0e7d431c2494c8e65560563f3aae Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 11 Jun 2013 13:04:30 +0200 Subject: [PATCH] Implement z_HTTP_header_remove --- include/yaz/zgdu.h | 6 ++++-- src/http.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/yaz/zgdu.h b/include/yaz/zgdu.h index 5ce5e47..38f4df3 100644 --- a/include/yaz/zgdu.h +++ b/include/yaz/zgdu.h @@ -84,8 +84,10 @@ YAZ_EXPORT void z_HTTP_header_add_content_type(ODR o, Z_HTTP_Header **hp, YAZ_EXPORT void z_HTTP_header_add_basic_auth(ODR o, Z_HTTP_Header **hp, const char *username, const char *password); - -YAZ_EXPORT const char *z_HTTP_header_lookup(const Z_HTTP_Header *hp, const char *n); +YAZ_EXPORT const char *z_HTTP_header_lookup(const Z_HTTP_Header *hp, + const char *n); +YAZ_EXPORT const char *z_HTTP_header_remove(Z_HTTP_Header **hp, + const char *n); YAZ_EXPORT const char *z_HTTP_errmsg(int code); diff --git a/src/http.c b/src/http.c index e4eecb9..6819e5f 100644 --- a/src/http.c +++ b/src/http.c @@ -219,6 +219,21 @@ void z_HTTP_header_set(ODR o, Z_HTTP_Header **hp, const char *n, (*hp)->next = 0; } +const char *z_HTTP_header_remove(Z_HTTP_Header **hp, const char *n) +{ + while (*hp) + { + if (!yaz_strcasecmp((*hp)->name, n)) + { + const char *v = (*hp)->value; + *hp = (*hp)->next; + return v; + } + hp = &(*hp)->next; + } + return 0; +} + const char *z_HTTP_header_lookup(const Z_HTTP_Header *hp, const char *n) { for (; hp; hp = hp->next) -- 1.7.10.4