From: Mike Hommey Date: Sun, 18 Jan 2009 08:04:30 GMT Subject: [WIP Patch 05/12] Use the new http API in get_refs_via_curl() Message-ID: <1232265877-3649-6-git-send-email-mh@glandium.org> In-Reply-To: <1232265877-3649-5-git-send-email-mh@glandium.org> Signed-off-by: Mike Hommey --- 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