{"thread":{"id":"2907","subject":"[PATCH] Fix for http-fetch from file:// URLs","startedAt":"2005-12-22T17:09:05Z","lastAt":"2005-12-22T17:09:05Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13945","messageId":"20051222170905.GB3876@reactrix.com","threadId":"2907","inReplyTo":null,"subject":"[PATCH] Fix for http-fetch from file:// URLs","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-12-22T17:09:05Z","receivedAt":"2005-12-22T17:09:05Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Recognize missing files when using http-fetch with file:// URLs\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\nBy way of explanation, our content distribution clients use a\nself-referential file:// URL when fetching updates, and all actual\ncontent servers are listed in http-alternates.  This removes the\ndependency on a single external primary server so updates will\ncontinue to work as long as any one server is available.\n\n http-fetch.c |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\napplies-to: 3ca81810fe174dec38fa6ccec874559a39d8893f\n92865a7cc1ea511f88d1ab8aa4c0faa50e05566b\ndiff --git a/http-fetch.c b/http-fetch.c\nindex 3cd6ef9..61b2188 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -267,7 +267,8 @@ static void process_object_response(void\n \tobj_req->state = COMPLETE;\n \n \t/* Use alternates if necessary */\n-\tif (obj_req->http_code == 404) {\n+\tif (obj_req->http_code == 404 ||\n+\t    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {\n \t\tfetch_alternates(alt->base);\n \t\tif (obj_req->repo->next != NULL) {\n \t\t\tobj_req->repo =\n@@ -475,7 +476,8 @@ static void process_alternates_response(\n \t\t\t}\n \t\t}\n \t} else if (slot->curl_result != CURLE_OK) {\n-\t\tif (slot->http_code != 404) {\n+\t\tif (slot->http_code != 404 &&\n+\t\t    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {\n \t\t\tgot_alternates = -1;\n \t\t\treturn;\n \t\t}\n@@ -637,7 +639,8 @@ static int fetch_indices(struct alt_base\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tif (slot->curl_result != CURLE_OK) {\n-\t\t\tif (slot->http_code == 404) {\n+\t\t\tif (slot->http_code == 404 ||\n+\t\t\t    slot->curl_result == CURLE_FILE_COULDNT_READ_FILE) {\n \t\t\t\trepo->got_indices = 1;\n \t\t\t\tfree(buffer.buffer);\n \t\t\t\treturn 0;\n@@ -802,7 +805,8 @@ static int fetch_object(struct alt_base \n \t\tret = error(\"Request for %s aborted\", hex);\n \t} else if (obj_req->curl_result != CURLE_OK &&\n \t\t   obj_req->http_code != 416) {\n-\t\tif (obj_req->http_code == 404)\n+\t\tif (obj_req->http_code == 404 ||\n+\t\t    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)\n \t\t\tret = -1; /* Be silent, it is probably in a pack. */\n \t\telse\n \t\t\tret = error(\"%s (curl_result = %d, http_code = %ld, sha1 = %s)\",\n---\n0.99.9.GIT\n"}]}