{"thread":{"id":"31613","subject":"[PATCH] Enable info/refs gzip decompression in HTTP client","startedAt":"2012-09-19T23:12:02Z","lastAt":"2012-09-20T02:59:45Z","messageCount":3,"participants":["Shawn O. Pearce","Junio C Hamano","Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"199544","messageId":"1348096322-21426-1-git-send-email-spearce@spearce.org","threadId":"31613","inReplyTo":null,"subject":"[PATCH] Enable info/refs gzip decompression in HTTP client","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2012-09-19T23:12:02Z","receivedAt":"2012-09-19T23:12:02Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"From: \"Shawn O. Pearce\" <spearce@spearce.org>\n\nSome HTTP servers try to use gzip compression on the /info/refs\nrequest to save transfer bandwidth. Repositories with many tags\nmay find the /info/refs request can be gzipped to be 50% of the\noriginal size due to the few but often repeated bytes used (hex\nSHA-1 and commonly digits in tag names).\n\nFor most HTTP requests enable \"Accept-Encoding: gzip\" ensuring\nthe /info/refs payload can use this encoding format.\n\nDisable the Accept-Encoding header on probe RPCs as response bodies\nare supposed to be exactly 4 bytes long, \"0000\". The HTTP headers\nrequesting and indicating compression use more space than the data\ntransferred in the body.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n http.c                | 1 +\n remote-curl.c         | 4 ++--\n t/t5551-http-fetch.sh | 3 ++-\n 3 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 9bac1d8..345c171 100644\n--- a/http.c\n+++ b/http.c\n@@ -818,6 +818,7 @@ static int http_request(const char *url, void *result, int target, int options)\n \n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"gzip\");\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 3ec474f..4a0927e 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -393,7 +393,7 @@ static int probe_rpc(struct rpc_state *rpc)\n \tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n+\tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, \"0000\");\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n@@ -449,7 +449,7 @@ static int post_rpc(struct rpc_state *rpc)\n \tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n+\tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"gzip\");\n \n \theaders = curl_slist_append(headers, rpc->hdr_content_type);\n \theaders = curl_slist_append(headers, rpc->hdr_accept);\ndiff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh\nindex 2db5c35..380c175 100755\n--- a/t/t5551-http-fetch.sh\n+++ b/t/t5551-http-fetch.sh\n@@ -32,13 +32,14 @@ setup_askpass_helper\n cat >exp <<EOF\n > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1\n > Accept: */*\n+> Accept-Encoding: gzip\n > Pragma: no-cache\n < HTTP/1.1 200 OK\n < Pragma: no-cache\n < Cache-Control: no-cache, max-age=0, must-revalidate\n < Content-Type: application/x-git-upload-pack-advertisement\n > POST /smart/repo.git/git-upload-pack HTTP/1.1\n-> Accept-Encoding: deflate, gzip\n+> Accept-Encoding: gzip\n > Content-Type: application/x-git-upload-pack-request\n > Accept: application/x-git-upload-pack-result\n > Content-Length: xxx\n-- \n1.7.12.1.510.g5dd77d8\n"},{"id":"199559","messageId":"7vtxutcymr.fsf@alter.siamese.dyndns.org","threadId":"31613","inReplyTo":"1348096322-21426-1-git-send-email-spearce@spearce.org","subject":"Re: [PATCH] Enable info/refs gzip decompression in HTTP client","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-20T00:43:24Z","receivedAt":"2012-09-20T00:43:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> From: \"Shawn O. Pearce\" <spearce@spearce.org>\n>\n> Some HTTP servers try to use gzip compression on the /info/refs\n> request to save transfer bandwidth. Repositories with many tags\n> may find the /info/refs request can be gzipped to be 50% of the\n> original size due to the few but often repeated bytes used (hex\n> SHA-1 and commonly digits in tag names).\n>\n> For most HTTP requests enable \"Accept-Encoding: gzip\" ensuring\n> the /info/refs payload can use this encoding format.\n>\n> Disable the Accept-Encoding header on probe RPCs as response bodies\n> are supposed to be exactly 4 bytes long, \"0000\". The HTTP headers\n> requesting and indicating compression use more space than the data\n> transferred in the body.\n\nAll of the above sounds very convincing, but ...\n\n> diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh\n> index 2db5c35..380c175 100755\n> --- a/t/t5551-http-fetch.sh\n> +++ b/t/t5551-http-fetch.sh\n> @@ -32,13 +32,14 @@ setup_askpass_helper\n>  cat >exp <<EOF\n>  > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1\n>  > Accept: */*\n> +> Accept-Encoding: gzip\n>  > Pragma: no-cache\n>  < HTTP/1.1 200 OK\n>  < Pragma: no-cache\n>  < Cache-Control: no-cache, max-age=0, must-revalidate\n>  < Content-Type: application/x-git-upload-pack-advertisement\n>  > POST /smart/repo.git/git-upload-pack HTTP/1.1\n> -> Accept-Encoding: deflate, gzip\n> +> Accept-Encoding: gzip\n\n... was loss of \"deflate\" intended?  If so why?  Could you explain\nit in the log message?\n\n>  > Content-Type: application/x-git-upload-pack-request\n>  > Accept: application/x-git-upload-pack-result\n>  > Content-Length: xxx\n"},{"id":"199563","messageId":"CAJo=hJtUOQK8iYXa3zMm2c5NEF-6s=v4MHYWhxADohKmRrqe9Q@mail.gmail.com","threadId":"31613","inReplyTo":"7vtxutcymr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Enable info/refs gzip decompression in HTTP client","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2012-09-20T02:59:45Z","receivedAt":"2012-09-20T02:59:45Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Wed, Sep 19, 2012 at 5:43 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> -> Accept-Encoding: deflate, gzip\n>> +> Accept-Encoding: gzip\n>\n> ... was loss of \"deflate\" intended?  If so why?  Could you explain\n> it in the log message?\n\nYes. I would add the following to the end of the commit message as a\nnew paragraph, please amend this for me:\n\n--8<--\nOnly request gzip encoding from servers. Although deflate is\nsupported by libcurl, most servers have standardized on gzip\nencoding for compression as that is what most browsers support.\nAsking for deflate increases request sizes by a few bytes, but\nis unlikely to ever be used by a server.\n-->8--\n"}]}