[Bug debuginfod/27277] Describe retrieved files when verbose

Noah Sanci nsanci@redhat.com
Fri Sep 10 18:22:00 GMT 2021


Hello,

The updated patch is attached.

On Wed, Sep 8, 2021 at 4:56 PM Mark Wielaard <mark@klomp.org> wrote:
> 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).
Should be good.

> > 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".
Fixed

> > 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.
Fixed

> > +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).
Fixed
> The last sentence has too many "the". I think a word is
> missing between the last two.
Not sure if what I did is considered a fix

Thanks,
Noah Sanci
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-debuginfod-PR27277-Describe-retrieved-files-when-ver.patch
Type: text/x-patch
Size: 21636 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20210910/d4168052/attachment-0001.bin>


More information about the Elfutils-devel mailing list