On Thu, Mar 31, 2022 at 1:44 PM Mark Wielaard <m...@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