summaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-09-28 08:31:23 (GMT)
committerJonathan Nieder <jrnieder@gmail.com>2013-10-01 00:21:59 (GMT)
commit1bbcc224ccfdccd99b1221d83150a8ffb8059ffd (patch)
tree5aed8889b6e9101caad031a123cb180432cd579e /remote-curl.c
parent132b70a2ed6d952e8142981474b41884ff93b780 (diff)
downloadgit-1bbcc224ccfdccd99b1221d83150a8ffb8059ffd.zip
git-1bbcc224ccfdccd99b1221d83150a8ffb8059ffd.tar.gz
git-1bbcc224ccfdccd99b1221d83150a8ffb8059ffd.tar.bz2
http: refactor options to http_get_*
Over time, the http_get_strbuf function has grown several optional parameters. We now have a bitfield with multiple boolean options, as well as an optional strbuf for returning the content-type of the response. And a future patch in this series is going to add another strbuf option. Treating these as separate arguments has a few downsides: 1. Most call sites need to add extra NULLs and 0s for the options they aren't interested in. 2. The http_get_* functions are actually wrappers around 2 layers of low-level implementation functions. We have to pass these options through individually. 3. The http_get_strbuf wrapper learned these options, but nobody bothered to do so for http_get_file, even though it is backed by the same function that does understand the options. Let's consolidate the options into a single struct. For the common case of the default options, we'll allow callers to simply pass a NULL for the options struct. The resulting code is often a few lines longer, but it ends up being easier to read (and to change as we add new options, since we do not need to update each call site). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 5b3ce9e..ed1499b 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -187,6 +187,7 @@ static struct discovery* discover_refs(const char *service, int for_push)
struct discovery *last = last_discovery;
char *refs_url;
int http_ret, maybe_smart = 0;
+ struct http_get_options options;
if (last && !strcmp(service, last->service))
return last;
@@ -204,8 +205,12 @@ static struct discovery* discover_refs(const char *service, int for_push)
}
refs_url = strbuf_detach(&buffer, NULL);
- http_ret = http_get_strbuf(refs_url, &type, &buffer,
- HTTP_NO_CACHE | HTTP_KEEP_ERROR);
+ memset(&options, 0, sizeof(options));
+ options.content_type = &type;
+ options.no_cache = 1;
+ options.keep_error = 1;
+
+ http_ret = http_get_strbuf(refs_url, &buffer, &options);
switch (http_ret) {
case HTTP_OK:
break;