From: Mark Wielaard <mark@klomp.org>
To: Noah Sanci <nsanci@redhat.com>, elfutils-devel@sourceware.org
Subject: Re: [Bug debuginfod/27277] Describe retrieved files when verbose
Date: Thu, 04 Aug 2022 15:12:14 +0200 [thread overview]
Message-ID: <625c4cfc6232c747e6b708aa42eaf0018d821f29.camel@klomp.org> (raw)
In-Reply-To: <CAJXA7qhS26rZPG3kyuFCbfWFdfMdJEjTMVO=NFhiUhHvP0kS1g@mail.gmail.com>
Hi Noah,
On Thu, 2022-07-14 at 11:32 -0400, Noah Sanci via Elfutils-devel wrote:
> Please find the patch for pr28284 attached
>
> Debuginfod and debuginfod clients are now equipped to send
> and receive http headers prefixed with X-DEBUGINFOD and
> print them in verbose mode for more context
OK, so this patch does 3 things:
- Introduce a debuginfod_get_headers public api for libdebuginfod
that provides any X-DEBUGINFOD prefixed headers for the last
retrieved file if the http(s) protocol was used (but not for the file
protocol nor when the file was found in the cache).
- It changes debuginfod-find to use this new api to show those headers
in verbose mode.
- Changes the debuginfod server to use the api to add any
X-DEBUGINFOD headers to the response if the request was
delegated.
So the last two are obvious once we have the first. I am slightly
worried about the "inconsistency" in when these headers are available.
Should we maybe cache them? Or do they only really make sense during
download/in the progress callback?
There currently are 3 special headers:
- X-DEBUGINFOD-FILE the (base) file name of the original file
- X-DEBUGINFOD-SIZE the on-disk size of the file
- X-DEBUGINFOD-ARCHIVE the archive name the file came from
All three are helpful for debug/verbose output. The size is independent
of the Content-Encoding and so is useful for progress
callback/filtering. The archive could be helpful if we had a mechanism
for getting all content such an archive.
The description of the new debuginfod_get_headers api is:
+.BR \%debuginfod_get_headers ()
+may be called with a debuginfod client. This function will return the
+http response headers prefixed with
+.BR X-DEBUGINFOD
+received from the first handle to get a response from a debuginfod server.
+Note that all other http headers aren't stored in the libcurl header
+callback function since they aren't of as much interest. The caller should
+copy the returned string if it is needed beyond the release of the client object.
+The returned string may be NULL if no headers are prefixed with
+.BR X-DEBUGINFOD
+\.
Looking at the headers the headers are cleaned up when a new request is
made using the same client object (not just when the client object is
released).
Also I am not getting any headers because they seem to be turned into
lower-case by curl. e.g. from debuginfod.fedoraproject.org:
< date: Thu, 04 Aug 2022 12:56:20 GMT
< content-type: application/octet-stream
< x-debuginfod-size: 4896240
< x-debuginfod-archive: /mnt/fedora_koji_prod/koji/packages/bash/5.1.16/2.fc36/x86_64/bash-debuginfo-5.1.16-2.fc36.x86_64.rpm
< x-debuginfod-file: /usr/lib/debug/usr/bin/bash-5.1.16-2.fc36.x86_64.debug
< last-modified: Wed, 19 Jan 2022 22:15:52 GMT
And according to the RFC "Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive." So at least in the code we always need to compare case-insensitive.
+ // X-DEBUGINFOD is 11 characters long.
+ // Some basic checks to ensure the headers received are of the expected format
+ if ( strncmp(buffer, "X-DEBUGINFOD", 11) || buffer[numitems-1] != '\n'
+ || (buffer == strstr(buffer, ":")) ){
+ return numitems;
+ }
and in debuginfod.cxx
+ // Clean winning headers to add all X-DEBUGINFOD lines to the pac
kage we'll send
+ while( (pos = header_dup.find("X-DEBUGINFOD")) != string::npos)
+ {
+ // Focus on where X-DEBUGINFOD- begins
I do wonder if we should simply say that the debuginfod_get_headers is only valid during a progress function callback. But maybe that is too restrictive. If not there is a slight difference between calling debuginfod_get_headers during a progress function and afterwards if there was an error during download (then we seem to clean them). Which probably good, but should be documented.
Also I probably won't mind providing all header, at least during the progress function callback. But you might be right that they aren't as informative.
Cheers,
Mark
next prev parent reply other threads:[~2022-08-04 13:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-04 18:54 Noah Sanci
2021-08-05 15:13 ` Mark Wielaard
2021-08-05 16:54 ` Frank Ch. Eigler
2021-08-06 10:04 ` Mark Wielaard
2021-08-06 18:54 ` Frank Ch. Eigler
2021-08-09 9:25 ` Mark Wielaard
2021-08-23 15:11 ` Noah Sanci
2021-08-24 8:18 ` Mark Wielaard
2021-08-27 18:38 ` Noah Sanci
2021-09-08 20:56 ` Mark Wielaard
2021-09-10 18:22 ` Noah Sanci
2021-09-12 19:08 ` Mark Wielaard
2021-09-13 20:07 ` Noah Sanci
2021-09-16 10:50 ` Mark Wielaard
2021-09-22 20:33 ` Frank Ch. Eigler
2021-09-29 14:55 ` Mark Wielaard
2021-09-29 21:28 ` Frank Ch. Eigler
2021-10-05 14:28 ` Mark Wielaard
2022-07-14 15:32 ` Noah Sanci
2022-08-04 13:12 ` Mark Wielaard [this message]
[not found] ` <CAJXA7qg09YkxK-NRQ31Hem0+54Us=jYC5+1siPSbHangx=SCow@mail.gmail.com>
2022-08-08 14:35 ` Mark Wielaard
2021-08-25 18:08 Noah Sanci
2021-09-08 15:01 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=625c4cfc6232c747e6b708aa42eaf0018d821f29.camel@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
--cc=nsanci@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).