]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod-client.c: Don't print empty line in header_callback
authorAaron Merey <amerey@redhat.com>
Wed, 1 Nov 2023 21:40:12 +0000 (17:40 -0400)
committerAaron Merey <amerey@redhat.com>
Wed, 1 Nov 2023 23:29:22 +0000 (19:29 -0400)
libcurl passes an empty line to header_callback indicating the end
of the response's HTTP headers.

Currently this empty line is printed to the debuginfod_client's
verbose_fd with a "header" prefix:

    $ echo $DEBUGINFOD_URLS
    https://debuginfod.fedoraproject.org/
    $ debuginfod-find -vv debuginfo e2bbf033b548021c37866429f12a99bd33bd6e8d
    [...]
    header x-fedora-requestid: ZULLx0PPA8nmj8c8Hw-RtAACgAE
    header server: Apache
    header
    [...]

Prevent this unnecessary line of output by only printing non-empty
lines in header_callback.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/debuginfod-client.c

index 6882cb190d3cc1742ea9e123705fd13bcaedc8a7..dcf0503163fd73e126a2197d278f363fd6839810 100644 (file)
@@ -568,7 +568,9 @@ header_callback (char * buffer, size_t size, size_t numitems, void * userdata)
   struct handle_data *data = (struct handle_data *) userdata;
   if (size != 1)
     return 0;
-  if (data->client && data->client->verbose_fd >= 0)
+  if (data->client
+      && data->client->verbose_fd >= 0
+      && numitems > 2)
     dprintf (data->client->verbose_fd, "header %.*s", (int)numitems, buffer);
   // Some basic checks to ensure the headers received are of the expected format
   if (strncasecmp(buffer, "X-DEBUGINFOD", 11)