Tell a serve that protocol v2 can be used by sending an http header indicating this. Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx> --- http.c | 7 +++++++ t/t5551-http-fetch-smart.sh | 2 ++ 2 files changed, 9 insertions(+) diff --git a/http.c b/http.c index fa8666a21..504a14a5a 100644 --- a/http.c +++ b/http.c @@ -896,6 +896,11 @@ static void set_from_env(const char **var, const char *envname) *var = val; } +static const char *get_version(void) +{ + return "Git-Protocol-Version: 2"; +} + void http_init(struct remote *remote, const char *url, int proactive_auth) { char *low_speed_limit; @@ -926,6 +931,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) if (remote) var_override(&http_proxy_authmethod, remote->http_proxy_authmethod); + extra_http_headers = curl_slist_append(extra_http_headers, get_version()); + pragma_header = curl_slist_append(http_copy_default_headers(), "Pragma: no-cache"); no_pragma_header = curl_slist_append(http_copy_default_headers(), diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index a51b7e20d..ce13f2425 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -27,6 +27,7 @@ cat >exp <<EOF > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 > Accept: */* > Accept-Encoding: gzip +> Git-Protocol-Version: 2 > Pragma: no-cache < HTTP/1.1 200 OK < Pragma: no-cache @@ -34,6 +35,7 @@ cat >exp <<EOF < Content-Type: application/x-git-upload-pack-advertisement > POST /smart/repo.git/git-upload-pack HTTP/1.1 > Accept-Encoding: gzip +> Git-Protocol-Version: 2 > Content-Type: application/x-git-upload-pack-request > Accept: application/x-git-upload-pack-result > Content-Length: xxx -- 2.14.1.342.g6490525c54-goog