From: Aaron Merey <amerey@redhat.com>
To: Mark Wielaard <mark@klomp.org>
Cc: elfutils-devel@sourceware.org
Subject: Re: [PATCH] [PATCH] debuginfod: Use the debuginfod-size response header
Date: Thu, 21 Apr 2022 16:53:44 -0400 [thread overview]
Message-ID: <CAJDtP-TPGr0Du+M8yQdtGfzv6hi4HXmwD0AjSVNmdnrcwh8P4w@mail.gmail.com> (raw)
In-Reply-To: <9e72049a6e8b9a964d68cfc70b98aea682911b13.camel@klomp.org>
On Thu, Mar 31, 2022 at 1:44 PM Mark Wielaard <mark@klomp.org> wrote:
> Just a question about this part:
>
> > + /* If Content-Length is -1, try to get the size from
> > + X-Debuginfod-Size */
> > + if (dl_size == -1 && c->winning_headers != NULL)
> > + {
> > + double xdl;
> > + char *hdr = strstr(c->winning_headers, "x-debuginfod-size");
> > +
> > + if (hdr != NULL
> > + && sscanf(hdr, "x-debuginfod-size: %lf", &xdl) == 1)
> > + dl_size = (xdl >= (double)(LONG_MAX+1UL) ? LONG_MAX : (long)xdl);
> > + }
> > + }
>
> In debuginfod.cxx the header is spelled all uppercase as "X-DEBUGINFOD-
> SIZE" which is also what is checked for in the run-debuginfod-response-
> headers.sh test. So shouldn't the above also be all uppercase or should
> you use strcasestr?
strcasestr is definitely better here. I meant to replace strstr with it
but it looks like I missed that.
> When using sscanf why are you using a double and %lf? Isn't it simpler
> to use a long and %ld?
It was done out of an (excessive) abundance of caution in case the
value from the header was greater than LONG_MAX. x-debuginfod-size is
derived from an off_t value so this currently isn't possible, so yes it
would be simpler to stick with long and %ld. Fixed.
> Is there a way to test this easily? When would Content-Length not be
> available?
AFAIK Content-Length isn't available only when a debuginfod server is
configured with an httpd proxy that compresses files on-the-fly. If the
response headers are finalized before compression is finished,
Content-Length won't be present.
Short of setting up an httpd-proxied server in the testsuite I'm not sure
exactly how to test this. We currently have tests that check for the
presence of x-debuginfod-size and we could add tests to at least verify
that the value in the header matches the uncompressed size of the file
being transferred.
Aaron
next prev parent reply other threads:[~2022-04-21 20:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 3:07 Aaron Merey
2022-03-31 17:37 ` Mark Wielaard
2022-04-21 20:53 ` Aaron Merey [this message]
2022-04-22 22:56 ` Aaron Merey
2022-04-24 15:04 ` Mark Wielaard
2022-04-25 15:03 ` Aaron Merey
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=CAJDtP-TPGr0Du+M8yQdtGfzv6hi4HXmwD0AjSVNmdnrcwh8P4w@mail.gmail.com \
--to=amerey@redhat.com \
--cc=elfutils-devel@sourceware.org \
--cc=mark@klomp.org \
/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).