{"thread":{"id":"57944","subject":"protocol: add Accept-Language header if possible","startedAt":"2022-06-02T03:18:55Z","lastAt":"2022-06-04T05:46:42Z","messageCount":4,"participants":["lilinchao@oschina.cn","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"456476","messageId":"2022060211034177301214@oschina.cn","threadId":"57944","inReplyTo":null,"subject":"protocol: add Accept-Language header if possible","fromName":"lilinchao@oschina.cn","fromEmail":"lilinchao@oschina.cn","sentAt":"2022-06-02T03:18:22Z","receivedAt":"2022-06-02T03:18:55Z","isPatch":false,"sender":{"key":"lilinchao@oschina.cn","avatar":null},"body":"Git server end's ability to accept Accept-Language header was introduced in f18604bbf2(http: add Accept-Language header if possible)\nbut it seems that only refs discovering stage has this ability:\n\"\n╰─$ GIT_CURL_VERBOSE=1 git ls-remote\n...\n10:42:36.939108 http.c:623              => Send header: GET /opensource/test.git/info/refs?service=git-upload-pack HTTP/1.1\n10:42:36.939112 http.c:623              => Send header: Host: gitee.com\n10:42:36.939114 http.c:623              => Send header: User-Agent: git/2.35.1.102.g2b9c120970\n10:42:36.939116 http.c:623              => Send header: Accept: */*\n10:42:36.939117 http.c:623              => Send header: Accept-Encoding: deflate, gzip\n10:42:36.939118 http.c:623              => Send header: Accept-Language: en-US, *;q=0.9\n10:42:36.939120 http.c:623              => Send header: Pragma: no-cache\n10:42:36.939121 http.c:623              => Send header: Git-Protocol: version=2\n10:42:36.939123 http.c:623              => Send header:\n...\n10:42:36.999012 http.c:611              => Send header, 0000000302 bytes (0x0000012e)\n10:42:36.999034 http.c:623              => Send header: GET /opensource/test.git/info/refs?service=git-upload-pack HTTP/1.1\n10:42:36.999039 http.c:623              => Send header: Host: gitee.com\n10:42:36.999041 http.c:623              => Send header: Authorization: Basic <redacted>\n10:42:36.999042 http.c:623              => Send header: User-Agent: git/2.35.1.102.g2b9c120970\n10:42:36.999044 http.c:623              => Send header: Accept: */*\n10:42:36.999063 http.c:623              => Send header: Accept-Encoding: deflate, gzip\n10:42:36.999081 http.c:623              => Send header: Accept-Language: en-US, *;q=0.9\n10:42:36.999101 http.c:623              => Send header: Pragma: no-cache\n10:42:36.999105 http.c:623              => Send header: Git-Protocol: version=2\n10:42:36.999106 http.c:623              => Send header:\n...\n10:42:37.098325 http.c:611              => Send header, 0000000341 bytes (0x00000155)\n10:42:37.098368 http.c:623              => Send header: POST /opensource/test.git/git-upload-pack HTTP/1.1\n10:42:37.098377 http.c:623              => Send header: Host: gitee.com\n10:42:37.098381 http.c:623              => Send header: Authorization: Basic <redacted>\n10:42:37.098384 http.c:623              => Send header: User-Agent: git/2.35.1.102.g2b9c120970\n10:42:37.098387 http.c:623              => Send header: Accept-Encoding: deflate, gzip\n10:42:37.098417 http.c:623              => Send header: Content-Type: application/x-git-upload-pack-request\n10:42:37.098421 http.c:623              => Send header: Accept: application/x-git-upload-pack-result\n10:42:37.098425 http.c:623              => Send header: Git-Protocol: version=2\n10:42:37.098428 http.c:623              => Send header: Content-Length: 118\n10:42:37.098431 http.c:623              => Send header:\n...\n\"\nWhy git-upload-pack/git-receive-pack stage doesn't enable this ability?\n\n\n--------------\nlilinchao@oschina.cn"},{"id":"456604","messageId":"202206040227197341312@oschina.cn","threadId":"57944","inReplyTo":"2022060211034177301214@oschina.cn","subject":"Re: protocol: add Accept-Language header if possible","fromName":"lilinchao@oschina.cn","fromEmail":"lilinchao@oschina.cn","sentAt":"2022-06-03T18:33:30Z","receivedAt":"2022-06-03T18:37:56Z","isPatch":false,"sender":{"key":"lilinchao@oschina.cn","avatar":null},"body":">Git server end's ability to accept Accept-Language header was introduced in f18604bbf2(http: add Accept-Language header if possible)\n>but it seems that only refs discovering stage has this ability:\n>\"\n>╰─$ GIT_CURL_VERBOSE=1 git ls-remote\n>...\n>10:42:36.939108 http.c:623              => Send header: GET /opensource/test.git/info/refs?service=git-upload-pack HTTP/1.1\n>10:42:36.939112 http.c:623              => Send header: Host: gitee.com\n>10:42:36.939114 http.c:623              => Send header: User-Agent: git/2.35.1.102.g2b9c120970\n>10:42:36.939116 http.c:623              => Send header: Accept: */*\n>10:42:36.939117 http.c:623              => Send header: Accept-Encoding: deflate, gzip\n>10:42:36.939118 http.c:623              => Send header: Accept-Language: en-US, *;q=0.9\n>10:42:36.939120 http.c:623              => Send header: Pragma: no-cache\n>10:42:36.939121 http.c:623              => Send header: Git-Protocol: version=2\n>10:42:36.939123 http.c:623              => Send header:\n>...\n>10:42:36.999012 http.c:611              => Send header, 0000000302 bytes (0x0000012e)\n>10:42:36.999034 http.c:623              => Send header: GET /opensource/test.git/info/refs?service=git-upload-pack HTTP/1.1\n>10:42:36.999039 http.c:623              => Send header: Host: gitee.com\n>10:42:36.999041 http.c:623              => Send header: Authorization: Basic <redacted>\n>10:42:36.999042 http.c:623              => Send header: User-Agent: git/2.35.1.102.g2b9c120970\n>10:42:36.999044 http.c:623              => Send header: Accept: */*\n>10:42:36.999063 http.c:623              => Send header: Accept-Encoding: deflate, gzip\n>10:42:36.999081 http.c:623              => Send header: Accept-Language: en-US, *;q=0.9\n>10:42:36.999101 http.c:623              => Send header: Pragma: no-cache\n>10:42:36.999105 http.c:623              => Send header: Git-Protocol: version=2\n>10:42:36.999106 http.c:623              => Send header:\n>...\n>10:42:37.098325 http.c:611              => Send header, 0000000341 bytes (0x00000155)\n>10:42:37.098368 http.c:623              => Send header: POST /opensource/test.git/git-upload-pack HTTP/1.1\n>10:42:37.098377 http.c:623              => Send header: Host: gitee.com\n>10:42:37.098381 http.c:623              => Send header: Authorization: Basic <redacted>\n>10:42:37.098384 http.c:623              => Send header: User-Agent: git/2.35.1.102.g2b9c120970\n>10:42:37.098387 http.c:623              => Send header: Accept-Encoding: deflate, gzip\n>10:42:37.098417 http.c:623              => Send header: Content-Type: application/x-git-upload-pack-request\n>10:42:37.098421 http.c:623              => Send header: Accept: application/x-git-upload-pack-result\n>10:42:37.098425 http.c:623              => Send header: Git-Protocol: version=2\n>10:42:37.098428 http.c:623              => Send header: Content-Length: 118\n>10:42:37.098431 http.c:623              => Send header:\n>...\n>\"\n>Why git-upload-pack/git-receive-pack stage doesn't enable this ability?\n>\nCan anyone tell me if this design is intentional."},{"id":"456625","messageId":"xmqqczfpfttb.fsf@gitster.g","threadId":"57944","inReplyTo":"202206040227197341312@oschina.cn","subject":"Re: protocol: add Accept-Language header if possible","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-06-03T19:09:04Z","receivedAt":"2022-06-03T19:09:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"lilinchao@oschina.cn\" <lilinchao@oschina.cn> writes:\n\nI am not your personal help-desk.  Please don't Cc: questions to me\nunless it is a piece of code I wrote and am familiar with.\n\nBut since you added an explicit CC, let me try.  Do not expect any\nhigh quality answers, though.\n\n>>Git server end's ability to accept Accept-Language header was\n>>introduced in f18604bbf2(http: add Accept-Language header if\n>>possible) but it seems that only refs discovering stage has this\n>>ability:\n\nI do not think we do anything special on the server end.  The said\ncommit taught client side to learn end-user's locale and throw\naccept-language header at the other side.\n\nI am not sure how much it helps in the smart HTTP, especially in\nlater phases of the transfer, in the first place.  Back in dumb HTTP\nwalker days, a failure to fetch single object would have resulted in\nan error message generated by the webserver directly shown at the\nclient end, but is that still true even if we use the smart HTTP to\nencapsulate the git native protocol exchange?\n\nI highly suspect that any calls to get_accept_language() helper, or\nfailure to call it, in the smart HTTP codepath is not something\ndesigned but just happened by accident.  If it helps to issue the\nheader to various requests, I think it would be good for\nconsistency.  Anything that uses http.c::http_request() should get\nthe header for free, so depending on the reason why some requests do\nnot use it, adding it might involve some refactoring, though.\n"},{"id":"456654","messageId":"2022060413415461823368@oschina.cn","threadId":"57944","inReplyTo":"xmqqczfpfttb.fsf@gitster.g","subject":"Re: Re: protocol: add Accept-Language header if possible","fromName":"lilinchao@oschina.cn","fromEmail":"lilinchao@oschina.cn","sentAt":"2022-06-04T05:46:29Z","receivedAt":"2022-06-04T05:46:42Z","isPatch":false,"sender":{"key":"lilinchao@oschina.cn","avatar":null},"body":"\n>\"lilinchao@oschina.cn\" <lilinchao@oschina.cn> writes:\n>\n>I am not your personal help-desk.  Please don't Cc: questions to me\n>unless it is a piece of code I wrote and am familiar with.\nFirst of all, sorry to disturb you, I thought you're the person most familiar\nwith those codes :)\nThis is not just a question, as I am planing to do some work on git to let\nserver side know the client end locale info for every HTTP request, this is\nvery helpful for many non-English speakers to understand what happened\nwhen git throw some error messages.\nBut first I want to know if it is worth doing, and I'm curious to know\nthe original design purpose, especially when I see inconsistent behavior,\nso I came here for help.\n>But since you added an explicit CC, let me try.  Do not expect any\n>high quality answers, though.\n>\nThanks a lot\nPS: I've tried to Cc Yi EungJun <eungjun.yi@navercorp.com> but my email\nwas returned, because \"The receiving address does not exist, or the receiving\naddress is disabled.\". So I don't know who I should Cc to now.\n\n>>>Git server end's ability to accept Accept-Language header was\n>>>introduced in f18604bbf2(http: add Accept-Language header if\n>>>possible) but it seems that only refs discovering stage has this\n>>>ability:\n>\n>I do not think we do anything special on the server end.  The said\n>commit taught client side to learn end-user's locale and throw\n>accept-language header at the other side.\n>\n>I am not sure how much it helps in the smart HTTP, especially in\n>later phases of the transfer, in the first place.  Back in dumb HTTP\n>walker days, a failure to fetch single object would have resulted in\n>an error message generated by the webserver directly shown at the\n>client end, but is that still true even if we use the smart HTTP to\n>encapsulate the git native protocol exchange?\n>\n>I highly suspect that any calls to get_accept_language() helper, or\n>failure to call it, in the smart HTTP codepath is not something\n>designed but just happened by accident.  If it helps to issue the\n>header to various requests, I think it would be good for\n>consistency.  Anything that uses http.c::http_request() should get\n>the header for free, so depending on the reason why some requests do\n>not use it, adding it might involve some refactoring, though.\n\nI think every HTTP request from git client should send this header to server\nend, to tell the server which language it prefers, this would be very friendly\nfor user end."}]}