diff options
| author | Konrad Kleine <kkleine@redhat.com> | 2020-02-26 10:00:43 -0500 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2020-02-26 21:10:40 +0100 |
| commit | 4c1de9608b67f5c7e71f4a2865395703224cb1cb (patch) | |
| tree | 5d65f2e84878b9b428861b10cb34a85715b4c626 /debuginfod | |
| parent | 37d56e9275fcf70c4a0cb19c0f2ac1d4032acfab (diff) | |
| download | platform_external_elfutils-4c1de9608b67f5c7e71f4a2865395703224cb1cb.tar.gz platform_external_elfutils-4c1de9608b67f5c7e71f4a2865395703224cb1cb.tar.bz2 platform_external_elfutils-4c1de9608b67f5c7e71f4a2865395703224cb1cb.zip | |
debuginfod: file:// URLs: handle curl resp. code
When file:// is used for DEBUGINFOD_URLS, then the response code for a
successful server query is 0 and not 200.
Using file:// can be helpful when you want to test your
debuginfod-client integration against a mocked file tree that mimics the
HTTP URLs from the debuginfod server. This way you don't have to run the
debuginfod server at all.
Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=25600
Signed-off-by: Konrad Kleine <kkleine@redhat.com>
Diffstat (limited to 'debuginfod')
| -rw-r--r-- | debuginfod/ChangeLog | 5 | ||||
| -rw-r--r-- | debuginfod/debuginfod-client.c | 38 |
2 files changed, 31 insertions, 12 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 16e14309..70970504 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2020-02-26 Konrad Kleine <kkleine@redhat.com> + + * debuginfod-client.c (debuginfod_query_server): Handle curl's + response code correctly when DEBUGINFOD_URLS begin with file:// + 2020-02-25 Frank Ch. Eigler <fche@redhat.com> * debuginfod.cxx (parse_opt): Treat -R as if -Z.rpm . diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 186aa90a..c1174486 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -716,20 +716,34 @@ debuginfod_query_server (debuginfod_client *c, else { /* Query completed without an error. Confirm that the - response code is 200 and set verified_handle. */ - long resp_code = 500; - CURLcode curl_res; - - curl_res = curl_easy_getinfo(target_handle, - CURLINFO_RESPONSE_CODE, - &resp_code); + response code is 200 when using HTTP/HTTPS and 0 when + using file:// and set verified_handle. */ - if (curl_res == CURLE_OK - && resp_code == 200 - && msg->easy_handle != NULL) + if (msg->easy_handle != NULL) { - verified_handle = msg->easy_handle; - break; + char *effective_url = NULL; + long resp_code = 500; + CURLcode ok1 = curl_easy_getinfo (target_handle, + CURLINFO_EFFECTIVE_URL, + &effective_url); + CURLcode ok2 = curl_easy_getinfo (target_handle, + CURLINFO_RESPONSE_CODE, + &resp_code); + if(ok1 == CURLE_OK && ok2 == CURLE_OK && effective_url) + { + if (strncmp (effective_url, "http", 4) == 0) + if (resp_code == 200) + { + verified_handle = msg->easy_handle; + break; + } + if (strncmp (effective_url, "file", 4) == 0) + if (resp_code == 0) + { + verified_handle = msg->easy_handle; + break; + } + } } } } |
