{"thread":{"id":"19472","subject":"[PATCH 11/18] transport: use the new http API in get_refs_via_curl()","startedAt":"2009-05-24T14:19:55Z","lastAt":"2009-05-24T14:19:55Z","messageCount":1,"participants":["Tay Ray Chuan"],"isPatch":true,"patchVersion":1,"patchTotal":18},"messages":[{"id":"114563","messageId":"20090524221955.2969ab4f.rctay89@gmail.com","threadId":"19472","inReplyTo":null,"subject":"[PATCH 11/18] transport: use the new http API in get_refs_via_curl()","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-05-24T14:19:55Z","receivedAt":"2009-05-24T14:19:55Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Signed-off-by: Mike Hommey <mh@glandium.org>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n transport.c |   32 ++++++++++----------------------\n 1 files changed, 10 insertions(+), 22 deletions(-)\n\ndiff --git a/transport.c b/transport.c\nindex b7c1c39..ab817f0 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -439,9 +439,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)\n \tchar *ref_name;\n \tchar *refs_url;\n \tint i = 0;\n-\n-\tstruct active_request_slot *slot;\n-\tstruct slot_results results;\n+\tint http_ret;\n\n \tstruct ref *refs = NULL;\n \tstruct ref *ref = NULL;\n@@ -461,25 +459,13 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)\n \trefs_url = xmalloc(strlen(transport->url) + 11);\n \tsprintf(refs_url, \"%s/info/refs\", transport->url);\n\n-\tslot = get_active_slot();\n-\tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);\n-\n-\tif (start_active_slot(slot)) {\n-\t\trun_active_slot(slot);\n-\t\tif (results.curl_result != CURLE_OK) {\n-\t\t\tstrbuf_release(&buffer);\n-\t\t\tif (missing_target(&results))\n-\t\t\t\tdie(\"%s not found: did you run git update-server-info on the server?\", refs_url);\n-\t\t\telse\n-\t\t\t\tdie(\"%s download error - %s\", refs_url, curl_errorstr);\n-\t\t}\n-\t} else {\n-\t\tstrbuf_release(&buffer);\n-\t\tdie(\"Unable to start HTTP request\");\n+\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n+\tif (http_ret == HTTP_MISSING_TARGET)\n+\t\tdie(\"%s not found: did you run git update-server-info on the\"\n+\t\t    \" server?\", refs_url);\n+\telse if (http_ret != HTTP_OK) {\n+\t\thttp_error(refs_url, http_ret);\n+\t\tgoto cleanup;\n \t}\n\n \tdata = buffer.buf;\n@@ -519,6 +505,8 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)\n \t\tfree(ref);\n \t}\n\n+cleanup:\n+\tstrbuf_release(&buffer);\n \tfree(refs_url);\n \treturn refs;\n }\n--\n1.6.3.1\n"}]}