summaryrefslogtreecommitdiff
path: root/http.h
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2009-06-06 16:43:53 +0800
committerJunio C Hamano <gitster@pobox.com>2009-06-06 10:56:27 -0700
commite929cd20bb3557833765f95fe0e9143a47f806e7 (patch)
treedd136a97f02f20db4402173cbd270f8ac04fd830 /http.h
parent5ace994f3384726fa993de526fc059d1343a6463 (diff)
downloadgit-e929cd20bb3557833765f95fe0e9143a47f806e7.tar.gz
http.c: new functions for the http API
The new functions added are: - http_request() (internal function) - http_get_strbuf() - http_get_file() - http_error() http_get_strbuf and http_get_file allow respectively to retrieve contents of an URL to a strbuf or an opened file handle. http_error prints out an error message containing the URL and the curl error (in curl_errorstr). 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 'http.h')
-rw-r--r--http.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/http.h b/http.h
index 1ef7dc1583..3d878d5126 100644
--- a/http.h
+++ b/http.h
@@ -114,6 +114,36 @@ static inline int missing__target(int code, int result)
#define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
+/* Options for http_request_*() */
+#define HTTP_NO_CACHE 1
+
+/* Return values for http_request_*() */
+#define HTTP_OK 0
+#define HTTP_MISSING_TARGET 1
+#define HTTP_ERROR 2
+#define HTTP_START_FAILED 3
+
+/*
+ * Requests an url and stores the result in a strbuf.
+ *
+ * If the result pointer is NULL, a HTTP HEAD request is made instead of GET.
+ */
+int http_get_strbuf(const char *url, struct strbuf *result, int options);
+
+/*
+ * Downloads an url and stores the result in the given file.
+ *
+ * If a previous interrupted download is detected (i.e. a previous temporary
+ * file is still around) the download is resumed.
+ */
+int http_get_file(const char *url, const char *filename, int options);
+
+/*
+ * Prints an error message using error() containing url and curl_errorstr,
+ * and returns ret.
+ */
+int http_error(const char *url, int ret);
+
extern int http_fetch_ref(const char *base, struct ref *ref);
#endif /* HTTP_H */