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>
Mike Hommey committed
Jun 6, 2009 at 16:43 UTC
28307b99ddb8e7284793d5ec830af10f130fa287
1 file changed
+12
-22
transport.c
+12
-22
@@ -439,9 +439,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
439
char *ref_name;
440
char *refs_url;
441
int i = 0;
442
-
443
- struct active_request_slot *slot;
444
- struct slot_results results;
442
+ int http_ret;
443
444
struct ref *refs = NULL;
445
struct ref *ref = NULL;
@@ -461,25 +459,16 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
459
refs_url = xmalloc(strlen(transport->url) + 11);
460
sprintf(refs_url, "%s/info/refs", transport->url);
461
464
- slot = get_active_slot();
465
- slot->results = &results;
466
- curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
467
- curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
468
- curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);
469
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
470
-
471
- if (start_active_slot(slot)) {
472
- run_active_slot(slot);
473
- if (results.curl_result != CURLE_OK) {
474
- strbuf_release(&buffer);
475
- if (missing_target(&results))
476
- die("%s not found: did you run git update-server-info on the server?", refs_url);
477
- else
478
- die("%s download error - %s", refs_url, curl_errorstr);
479
- }
480
- } else {
481
- strbuf_release(&buffer);
482
- die("Unable to start HTTP request");
462
+ http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
463
+ switch (http_ret) {
464
+ case HTTP_OK:
465
+ break;
466
+ case HTTP_MISSING_TARGET:
467
+ die("%s not found: did you run git update-server-info on the"
468
+ " server?", refs_url);
469
+ default:
470
+ http_error(refs_url, http_ret);
471
+ die("HTTP request failed");
472
}
473
474
data = buffer.buf;
@@ -519,6 +508,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
508
free(ref);
509
}
510
511
+ strbuf_release(&buffer);
512
free(refs_url);
513
return refs;
514
}