* [PATCH 11/18] transport: use the new http API in get_refs_via_curl()
@ 2009-05-24 14:19 Tay Ray Chuan
0 siblings, 0 replies; only message in thread
From: Tay Ray Chuan @ 2009-05-24 14:19 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Johannes Schindelin, Mike Hommey
Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
transport.c | 32 ++++++++++----------------------
1 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/transport.c b/transport.c
index b7c1c39..ab817f0 100644
--- a/transport.c
+++ b/transport.c
@@ -439,9 +439,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
char *ref_name;
char *refs_url;
int i = 0;
-
- struct active_request_slot *slot;
- struct slot_results results;
+ int http_ret;
struct ref *refs = NULL;
struct ref *ref = NULL;
@@ -461,25 +459,13 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
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");
+ http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
+ if (http_ret == HTTP_MISSING_TARGET)
+ die("%s not found: did you run git update-server-info on the"
+ " server?", refs_url);
+ else if (http_ret != HTTP_OK) {
+ http_error(refs_url, http_ret);
+ goto cleanup;
}
data = buffer.buf;
@@ -519,6 +505,8 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
free(ref);
}
+cleanup:
+ strbuf_release(&buffer);
free(refs_url);
return refs;
}
--
1.6.3.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-24 14:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-24 14:19 [PATCH 11/18] transport: use the new http API in get_refs_via_curl() Tay Ray Chuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).