)]}'
{
  "commit": "8ee3e120cd167dcfd2b7399cce567c724dfef134",
  "tree": "05112cbeb48863e497bd2c34c3deb1f1bdbada0b",
  "parents": [
    "5f8b86db94e789bc07258f98cc5ba25d18273d83"
  ],
  "author": {
    "name": "Jeff King",
    "email": "peff@peff.net",
    "time": "Wed Feb 06 14:18:48 2019 -0500"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Wed Feb 06 12:20:19 2019 -0800"
  },
  "message": "remote-curl: refactor smart-http discovery\n\nAfter making initial contact with an http server, we have to decide if\nthe server supports smart-http, and if so, which version. Our rules are\na bit inconsistent:\n\n  1. For v0, we require that the content-type indicates a smart-http\n     response. We also require the response to look vaguely like a\n     pkt-line starting with \"#\". If one of those does not match, we fall\n     back to dumb-http.\n\n     But according to our http protocol spec[1]:\n\n       Dumb servers MUST NOT return a return type starting with\n       `application/x-git-`.\n\n     If we see the expected content-type, we should consider it\n     smart-http. At that point we can parse the pkt-line for real, and\n     complain if it is not syntactically valid.\n\n  2. For v2, we do not actually check the content-type. Our v2 protocol\n     spec says[2]:\n\n       When using the http:// or https:// transport a client makes a\n       \"smart\" info/refs request as described in `http-protocol.txt`[...]\n\n     and the http spec is clear that for a smart-http response[3]:\n\n       The Content-Type MUST be `application/x-$servicename-advertisement`.\n\n     So it is required according to the spec.\n\nThese inconsistencies were easy to miss because of the way the original\ncode was written as an inline conditional. Let\u0027s pull it out into its\nown function for readability, and improve a few things:\n\n - we now predicate the smart/dumb decision entirely on the presence of\n   the correct content-type\n\n - we do a real pkt-line parse before deciding how to proceed (and die\n   if it isn\u0027t valid)\n\n - use skip_prefix() for comparing service strings, instead of\n   constructing expected output in a strbuf; this avoids dealing with\n   memory cleanup\n\nNote that this _is_ tightening what the client will allow. It\u0027s all\naccording to the spec, but it\u0027s possible that other implementations\nmight violate these. However, violating these particular rules seems\nlike an odd choice for a server to make.\n\n[1] Documentation/technical/http-protocol.txt, l. 166-167\n[2] Documentation/technical/protocol-v2.txt, l. 63-64\n[3] Documentation/technical/http-protocol.txt, l. 247\n\nHelped-by: Josh Steadmon \u003csteadmon@google.com\u003e\nSigned-off-by: Jeff King \u003cpeff@peff.net\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2e04d53ac8e79c9f5a3839a7ab97fd67f2588021",
      "old_mode": 33188,
      "old_path": "remote-curl.c",
      "new_id": "c78ba83744451f50ee1a7db65a38d3cc0e984b2a",
      "new_mode": 33188,
      "new_path": "remote-curl.c"
    }
  ]
}
