From: Mark Wielaard <mark@klomp.org>
To: Noah Sanci <nsanci@redhat.com>
Cc: elfutils-devel@sourceware.org
Subject: Re: [Bug debuginfod/27277] Describe retrieved files when verbose
Date: Wed, 8 Sep 2021 22:56:00 +0200 [thread overview]
Message-ID: <YTkjYGlZnmdWafdG@wildebeest.org> (raw)
In-Reply-To: <CAJXA7qjE1f6jnymp7FoM=0pTXUpumFiSHeqk+mS-esuze7wDTg@mail.gmail.com>
Hi Noah,
Looks like I reviewed a slightly older version earlier. Could you
merge the reviewes/changes for both version in a new version of this
patch?
On Fri, Aug 27, 2021 at 02:38:27PM -0400, Noah Sanci via Elfutils-devel wrote:
> From ed7638571f188e346dd466c195b9ebda028d1c65 Mon Sep 17 00:00:00 2001
> From: Noah Sanci <nsanci@redhat.com>
> Date: Wed, 28 Jul 2021 14:46:05 -0400
> Subject: [PATCH] debuginfod: PR27277 - Describe retrieved files when verbose
>
> There appear to exist use cases that intend to simply check for the
> existence of content in a debuginfod server, without actually
> downloading it. In HTTP land, the HEAD operation is the natural
> expression of this.
> Instead of implementing a HEAD/describe option, allow users, with enough
> verbosity, to print the HTTP response headers upon retrieving a file.
Same comment as earlier, but now please also state the debuginfod
changes itself (the extra headers added).
> E.g output:
>
> HTTP/1.1 200 OK
> Connection: Keep-Alive
> Content-Length: 2428240
> Cache-Control: public
> Last-Modified: Sat, 15 May 2021 20:49:51 GMT
> X-FILE: "file name"
> X-FILE-SIZE: "byte length of file"
I think an actual output example is better than including "place
holder text".
> +2021-08-02 Noah Sanci <nsanci@redhat.com>
> +
> + PR27277
> + * debuginfod-client.c (struct debuginfod_client): New field
> + winning_headers.
> + (struct handle_data): New field response_data.
> + (header_callback): Store received headers in response_data.
> + (debuginfod_query_server): Activate CURLOPT_HEADERFUNCTION.
> + Save winning response_data.
> + (debuginfod_end): free client winning headers.
> + * debuginfod.cxx (handle_buildid_f_match): remove X-FILE path. Add
> + X-FILE and X-FILE-SIZE headers.
> + (handle_buildid_r_match): remove X-FILE path. Add X-FILE, X-FILE-SIZE
> + headers, and X-ARCHIVE headers.
So the changes compared to the other one are just in the
debuginfod.cxx file.
> diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
> index 6e182a84..e9b7e76c 100644
> --- a/debuginfod/debuginfod.cxx
> +++ b/debuginfod/debuginfod.cxx
> @@ -1068,6 +1068,9 @@ handle_buildid_f_match (bool internal_req_t,
> else
> {
> MHD_add_response_header (r, "Content-Type", "application/octet-stream");
> + std::string file = b_source0.substr(b_source0.find_last_of("/")+1, b_source0.length());
> + MHD_add_response_header (r, "X-FILE-SIZE", to_string(s.st_size).c_str() );
> + MHD_add_response_header (r, "X-FILE", file.c_str() );
> add_mhd_last_modified (r, s.st_mtime);
> if (verbose > 1)
> obatched(clog) << "serving file " << b_source0 << endl;
> @@ -1537,6 +1540,9 @@ handle_buildid_r_match (bool internal_req_p,
> inc_metric ("http_responses_total","result","archive fdcache");
>
> MHD_add_response_header (r, "Content-Type", "application/octet-stream");
> + MHD_add_response_header (r, "X-FILE-SIZE", to_string(fs.st_size).c_str());
> + MHD_add_response_header (r, "X-ARCHIVE", b_source0.c_str());
> + MHD_add_response_header (r, "X-FILE", b_source1.c_str());
> add_mhd_last_modified (r, fs.st_mtime);
> if (verbose > 1)
> obatched(clog) << "serving fdcache archive " << b_source0 << " file " << b_source1 << endl;
> @@ -1678,6 +1684,11 @@ handle_buildid_r_match (bool internal_req_p,
> else
> {
> MHD_add_response_header (r, "Content-Type", "application/octet-stream");
> + std::string file = b_source1.substr(b_source1.find_last_of("/")+1, b_source1.length());
> + MHD_add_response_header (r, "X-FILE-SIZE", to_string(fs.st_size).c_str());
> + MHD_add_response_header (r, "X-ARCHIVE", b_source0.c_str());
> + MHD_add_response_header (r, "X-FILE", file.c_str());
> +
> add_mhd_last_modified (r, archive_entry_mtime(e));
> if (verbose > 1)
> obatched(clog) << "serving archive " << b_source0 << " file " << b_source1 << endl;
This looks good. But I wonder if, since these are headers specific to
debuginfod, they shouldn't be named X-DEBUGINFOD-... Just to make sure
they don't clash with any others a proxy might insert.
> +2021-08-04 Noah Sanci <nsanci@redhat.com>
> +
> + PR27277
> + * debuginfod-find.1: Increasing verbosity describes the downloaded
> + file.
> + * debuginfod.8: Describe X-FILE, X-FILE-SIZE, and X-ARCHIVE.
> +
> diff --git a/doc/debuginfod.8 b/doc/debuginfod.8
> index 5b0d793c..e9c58fbb 100644
> --- a/doc/debuginfod.8
> +++ b/doc/debuginfod.8
> @@ -256,6 +256,13 @@ Unknown buildid / request combinations result in HTTP error codes.
> This file service resemblance is intentional, so that an installation
> can take advantage of standard HTTP management infrastructure.
>
> +Upon finding a file in an archive or simply in the database, some
> +custom http headers are added to the response. For files in the
> +database X-FILE and X-FILE-SIZE are added. X-FILE is simply the
> +filename and X-FILE-SIZE is the size of the file. For files found
> +in archives, in addition to X-FILE and X-FILE-SIZE, X-ARCHIVE is added.
> +X-ARCHIVE is the name of the the file was found in.
Probably should mention that the file name is unescaped (not url
encoded). The last sentence has too many "the". I think a word is
missing between the last two.
I have again not reviewed the testcase yet.
Cheers,
Mark
next prev parent reply other threads:[~2021-09-08 20:56 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 [this message]
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
[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=YTkjYGlZnmdWafdG@wildebeest.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).