{"thread":{"id":"19468","subject":"[PATCH 13/18] http-push: use the new http API in remote_exists()","startedAt":"2009-05-24T14:19:59Z","lastAt":"2009-05-24T14:19:59Z","messageCount":1,"participants":["Tay Ray Chuan"],"isPatch":true,"patchVersion":1,"patchTotal":18},"messages":[{"id":"114559","messageId":"20090524221959.e6b1be49.rctay89@gmail.com","threadId":"19468","inReplyTo":null,"subject":"[PATCH 13/18] http-push: use the new http API in remote_exists()","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-05-24T14:19:59Z","receivedAt":"2009-05-24T14:19:59Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Signed-off-by: Mike Hommey <mh@glandium.org>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c |   31 ++++++++++++-------------------\n 1 files changed, 12 insertions(+), 19 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex f2c8a97..5b20cec 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -2000,29 +2000,22 @@ static void update_remote_info_refs(struct remote_lock *lock)\n static int remote_exists(const char *path)\n {\n \tchar *url = xmalloc(strlen(repo->url) + strlen(path) + 1);\n-\tstruct active_request_slot *slot;\n-\tstruct slot_results results;\n-\tint ret = -1;\n+\tint ret;\n\n \tsprintf(url, \"%s%s\", repo->url, path);\n\n-\tslot = get_active_slot();\n-\tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);\n-\n-\tif (start_active_slot(slot)) {\n-\t\trun_active_slot(slot);\n-\t\tif (results.http_code == 404)\n-\t\t\tret = 0;\n-\t\telse if (results.curl_result == CURLE_OK)\n-\t\t\tret = 1;\n-\t\telse\n-\t\t\tfprintf(stderr, \"HEAD HTTP error %ld\\n\", results.http_code);\n-\t} else {\n-\t\tfprintf(stderr, \"Unable to start HEAD request\\n\");\n+\tswitch (http_get_strbuf(url, NULL, 0)) {\n+\tcase HTTP_OK:\n+\t\tret = 1;\n+\t\tbreak;\n+\tcase HTTP_MISSING_TARGET:\n+\t\tret = 0;\n+\t\tbreak;\n+\tcase HTTP_ERROR:\n+\t\thttp_error(url, HTTP_ERROR);\n+\tdefault:\n+\t\tret = -1;\n \t}\n-\n \tfree(url);\n \treturn ret;\n }\n--\n1.6.3.1\n"}]}