yaz_url_exec: only one User-Agent
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 1 May 2013 12:05:32 +0000 (14:05 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 1 May 2013 12:05:32 +0000 (14:05 +0200)
User-Agent in headers removes the default User-Agent: YAZ .

src/url.c

index 3c2b361..1c55261 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -112,6 +112,11 @@ Z_HTTP_Response *yaz_url_exec(yaz_url_t p, const char *uri,
         gdu = z_get_HTTP_Request_uri(p->odr_out, uri_lean, 0, p->proxy ? 1 : 0);
         gdu->u.HTTP_Request->method = odr_strdup(p->odr_out, method);
 
         gdu = z_get_HTTP_Request_uri(p->odr_out, uri_lean, 0, p->proxy ? 1 : 0);
         gdu->u.HTTP_Request->method = odr_strdup(p->odr_out, method);
 
+        /* clear all headers - including "User-Agent", if already in headers
+           z_get_HTTP_Request_uri sets "User-Agent" header */
+        if (z_HTTP_header_lookup(headers, "User-Agent"))
+            gdu->u.HTTP_Request->headers = 0;
+
         if (http_user && http_pass)
             z_HTTP_header_add_basic_auth(p->odr_out,
                                          &gdu->u.HTTP_Request->headers,
         if (http_user && http_pass)
             z_HTTP_header_add_basic_auth(p->odr_out,
                                          &gdu->u.HTTP_Request->headers,