aboutsummaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2009-06-06 16:43:54 +0800
committerJunio C Hamano <gitster@pobox.com>2009-06-06 11:03:07 -0700
commit28307b99ddb8e7284793d5ec830af10f130fa287 (patch)
tree9e4b41bb61c300acf4fcce2388eeb3980da9ba15 /transport.c
parente929cd20bb3557833765f95fe0e9143a47f806e7 (diff)
downloadgit-28307b99ddb8e7284793d5ec830af10f130fa287.tar.gz
git-28307b99ddb8e7284793d5ec830af10f130fa287.tar.xz
transport.c::get_refs_via_curl(): use the new http API
Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/transport.c b/transport.c
index b7c1c391c..2128c5872 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,16 @@ 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);
+ switch (http_ret) {
+ case HTTP_OK:
+ break;
+ case HTTP_MISSING_TARGET:
+ die("%s not found: did you run git update-server-info on the"
+ " server?", refs_url);
+ default:
+ http_error(refs_url, http_ret);
+ die("HTTP request failed");
}
data = buffer.buf;
@@ -519,6 +508,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
free(ref);
}
+ strbuf_release(&buffer);
free(refs_url);
return refs;
}