path: root/http.h
diff options
authorJeff King <>2019-03-24 12:08:38 (GMT)
committerJunio C Hamano <>2019-03-24 12:22:40 (GMT)
commita3722bcbbd850bf02aea19d58de112ef513cb2f1 (patch)
tree16f7cba4769ea47f38bea6cefb729bcfb7ceb5c2 /http.h
parent041f5ea1cf987a4068ef5f39ba0a09be85952064 (diff)
http: factor out curl result code normalization
We make some requests with CURLOPT_FAILONERROR and some without, and then handle_curl_result() normalizes any failures to a uniform CURLcode. There are some other code paths in the dumb-http walker which don't use handle_curl_result(); let's pull the normalization into its own function so it can be reused. Arguably those code paths would benefit from the rest of handle_curl_result(), notably the auth handling. But retro-fitting it now would be a lot of work, and in practice it doesn't matter too much (whatever authentication we needed to make the initial contact with the server is generally sufficient for the rest of the dumb-http requests). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'http.h')
1 files changed, 9 insertions, 0 deletions
diff --git a/http.h b/http.h
index 4eb4e80..f0d271b 100644
--- a/http.h
+++ b/http.h
@@ -136,6 +136,15 @@ static inline int missing__target(int code, int result)
#define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
+ * Normalize curl results to handle CURL_FAILONERROR (or lack thereof). Failing
+ * http codes have their "result" converted to CURLE_HTTP_RETURNED_ERROR, and
+ * an appropriate string placed in the errorstr buffer (pass curl_errorstr if
+ * you don't have a custom buffer).
+ */
+void normalize_curl_result(CURLcode *result, long http_code, char *errorstr,
+ size_t errorlen);
/* Helpers for modifying and creating URLs */
extern void append_remote_object_url(struct strbuf *buf, const char *url,
const char *hex,