[WIP Patch 05/12] Use the new http API in get_refs_via_curl()

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>
---
 transport.c |   27 ++++-----------------------
 1 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/transport.c b/transport.c
index 6919ff1..55bf274 100644
--- a/transport.c
+++ b/transport.c
@@ -432,9 +432,6 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 	char *refs_url;
 	int i = 0;
 
-	struct active_request_slot *slot;
-	struct slot_results results;
-
 	struct ref *refs = NULL;
 	struct ref *ref = NULL;
 	struct ref *last_ref = NULL;
@@ -450,26 +447,8 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 	refs_url = xmalloc(strlen(transport->url) + 11);
 	sprintf(refs_url, "%s/info/refs", transport->url);
 
-	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, refs_url);
-	curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
-
-	if (start_active_slot(slot)) {
-		run_active_slot(slot);
-		if (results.curl_result != CURLE_OK) {
-			strbuf_release(&buffer);
-			if (missing_target(&results))
-				die("%s not found: did you run git update-server-info on the server?", refs_url);
-			else
-				die("%s download error - %s", refs_url, curl_errorstr);
-		}
-	} else {
-		strbuf_release(&buffer);
-		die("Unable to start HTTP request");
-	}
+	if (http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE) != HTTP_OK)
+		goto cleanup;
 
 	data = buffer.buf;
 	start = NULL;
@@ -508,6 +487,8 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 		free(ref);
 	}
 
+cleanup:
+	strbuf_release(&buffer);
 	http_cleanup();
 	free(refs_url);
 	return refs;
-- 
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 05/12] Use the new http API in get_refs_via_curl(), 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)