From ab0e59628f09e57a8e89454749d3dcbf80538c18 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Fri, 2 Oct 2015 11:59:03 -0700 Subject: [PATCH] Treat HTTP 304 codes as non-fatal We set the If-Modified-Since header field for each GET request, and if the condition fails, the server will respond with HTTP 304. The 304 means the cached debuginfo is up-to-date, not requiring a fresh download. Since this condition is non-fatal, avoid swapping the download URLs in this case. --- src/server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server.c b/src/server.c index 10257bc..4e96285 100644 --- a/src/server.c +++ b/src/server.c @@ -122,7 +122,13 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp) fflush(file); // printf("HTTP return code is %i\n", ret); - if (ret != 200 && ret != 404) + /* HTTP 304 is returned if (a) the cached debuginfo has the same + * timestamp or is newer than that on the server and (b) we haven't + * already added the URL to the hash table. So, the first crash for a + * boot may result in a 304 if the debuginfo had been downloaded in a + * previous boot. + */ + if (ret != 200 && ret != 404 && ret != 304) urlcounter++; if (ret == 200) {