[WIP Patch 06/12] Use the new http API in http-walker.c:fetch_indices()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mike Hommey
Date: Sunday, January 18, 2009 - 1:04 am

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 http-walker.c |   31 ++++++++-----------------------
 1 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/http-walker.c b/http-walker.c
index 0139d1e..edcb779 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -648,9 +648,6 @@ static int fetch_indices(struct walker *walker, struct alt_base *repo)
 	int i = 0;
 	int ret = 0;
 
-	struct active_request_slot *slot;
-	struct slot_results results;
-
 	if (repo->got_indices)
 		return 0;
 
@@ -660,27 +657,15 @@ static int fetch_indices(struct walker *walker, struct alt_base *repo)
 	url = xmalloc(strlen(repo->base) + 21);
 	sprintf(url, "%s/objects/info/packs", repo->base);
 
-	slot = get_active_slot();
-	slot->results = &results;
-	curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
-	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
-	curl_easy_setopt(slot->curl, CURLOPT_URL, url);
-	curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
-	if (start_active_slot(slot)) {
-		run_active_slot(slot);
-		if (results.curl_result != CURLE_OK) {
-			if (missing_target(&results)) {
-				repo->got_indices = 1;
-				goto cleanup;
-			} else {
-				repo->got_indices = 0;
-				ret = error("%s", curl_errorstr);
-				goto cleanup;
-			}
-		}
-	} else {
+	switch (http_get_strbuf(url, &buffer, HTTP_NO_CACHE)) {
+	case HTTP_OK:
+		break;
+	case HTTP_MISSING_TARGET:
+		repo->got_indices = 1;
+		goto cleanup;
+	default:
 		repo->got_indices = 0;
-		ret = error("Unable to start request");
+		ret = -1;
 		goto cleanup;
 	}
 
-- 
1.6.1.141.gb32a

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] http-push: fix off-by-path_len, Johannes Schindelin, (Sat Jan 17, 8:36 am)
Where's Nick?, was Re: [PATCH] http-push: fix off-by-path_len, Johannes Schindelin, (Sat Jan 17, 8:40 am)
[PATCH] t5540: clarify that http-push does not handle pack ..., Johannes Schindelin, (Sat Jan 17, 8:41 am)
Re: [PATCH] http-push: fix off-by-path_len, Mike Hommey, (Sun Jan 18, 12:49 am)
[WIP Patch 00/12] Refactoring the http API, Mike Hommey, (Sun Jan 18, 1:04 am)
[WIP Patch 02/12] Some cleanup in get_refs_via_curl(), Mike Hommey, (Sun Jan 18, 1:04 am)
[WIP Patch 03/12] Two new functions for the http API, Mike Hommey, (Sun Jan 18, 1:04 am)
[WIP Patch 06/12] Use the new http API in http-walker.c:fe ..., Mike Hommey, (Sun Jan 18, 1:04 am)
Re: [WIP Patch 00/12] Refactoring the http API, Junio C Hamano, (Sun Jan 18, 1:30 am)
Re: [WIP Patch 00/12] Refactoring the http API, Mike Hommey, (Sun Jan 18, 2:12 am)
Re: [WIP Patch 00/12] Refactoring the http API, Boyd Stephen Smith Jr., (Sun Jan 18, 4:29 am)
Re: [WIP Patch 03/12] Two new functions for the http API, Johannes Schindelin, (Sun Jan 18, 8:03 am)
Re: [WIP Patch 04/12] Use the new http API in http_fetch_ref(), Johannes Schindelin, (Sun Jan 18, 8:10 am)
Re: [WIP Patch 05/12] Use the new http API in get_refs_via ..., Johannes Schindelin, (Sun Jan 18, 8:12 am)
Re: [WIP Patch 07/12] Use the new http API in http-push.c: ..., Johannes Schindelin, (Sun Jan 18, 8:14 am)
Re: [WIP Patch 08/12] Use the new http API in update_remot ..., Johannes Schindelin, (Sun Jan 18, 8:18 am)
Re: [WIP Patch 02/12] Some cleanup in get_refs_via_curl(), Johannes Schindelin, (Sun Jan 18, 12:06 pm)
Re: [WIP Patch 02/12] Some cleanup in get_refs_via_curl(), Johannes Schindelin, (Sun Jan 18, 12:11 pm)
Re: [WIP Patch 02/12] Some cleanup in get_refs_via_curl(), Johannes Schindelin, (Sun Jan 18, 2:09 pm)
Re: [WIP Patch 02/12] Some cleanup in get_refs_via_curl(), Johannes Schindelin, (Sun Jan 18, 2:10 pm)