el-get/methods
stephan-cr 3969e02b27
Fix Git HTTP smart host detection (#2854)
* Fix Git HTTP smart host detection

regression test test/issues/el-get-issue-1920.el revealed that Git
HTTP smart host detection is broken. Not all hosts support the HEAD
HTTP request method. For example, github.com for HEAD

(let ((url-request-method "HEAD"))
  (url-retrieve-synchronously
   "https://github.com/dimitri/el-get.git/info/refs\?service\=git-upload-pack"))

responds

HTTP/1.1 405 Method Not Allowed
Server: GitHub Babel 2.0
Content-Type: text/plain
Content-Security-Policy: default-src 'none'; sandbox
Content-Length: 0
X-Frame-Options: DENY
X-GitHub-Request-Id: C1DA:12E32:2B6C9D7:302B1C2:61C9A4E8

while for GET

(let ((url-request-method "GET"))
  (url-retrieve-synchronously
   "https://github.com/dimitri/el-get.git/info/refs\?service\=git-upload-pack"))

responds

HTTP/1.1 200 OK
Server: GitHub Babel 2.0
Content-Type: application/x-git-upload-pack-advertisement
Content-Security-Policy: default-src 'none'; sandbox
Transfer-Encoding: chunked
expires: Fri, 01 Jan 1980 00:00:00 GMT
pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate
Vary: Accept-Encoding
X-Frame-Options: DENY
X-GitHub-Request-Id: C22C:5E15:3923777:3D822AC:61CA332A

Other hosts like git.sr.ht do support HEAD, of course.

Furthermore, the HTTP status code wasn't checked, that's why hosts
like github.com would be classified as "dumb" hosts.

This commit checks the HTTP status code, and if the status is not 200
or 304 for the HEAD HTTP request method, it tries GET. HEAD is tried
first, because GET might be more expensive for big repositories.

The regression test is adapted as well.

* Fix byte compiler warnings
2023-01-01 13:31:18 +01:00
..
el-get-apt-get.el Force response "yes" in apt-get install 2020-09-03 21:57:55 +02:00
el-get-brew.el el-get-executable-find: use it consistently 2015-07-27 14:56:02 -04:00
el-get-builtin.el satisfy newer 24.4 byte compiler 2014-04-04 19:13:27 -04:00
el-get-bzr.el Don't install insecurely without el-get-allow-insecure. 2014-08-12 11:42:08 -07:00
el-get-cvs.el Don't install insecurely without el-get-allow-insecure. 2014-08-12 11:42:08 -07:00
el-get-darcs.el Don't install insecurely without el-get-allow-insecure. 2014-08-12 11:42:08 -07:00
el-get-elpa.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
el-get-emacsmirror.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
el-get-emacswiki.el Fix lambda invocation for Emacs 28 2021-06-13 16:03:08 +02:00
el-get-fink.el el-get-executable-find: use it consistently 2015-07-27 14:56:02 -04:00
el-get-fossil.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
el-get-git-svn.el Don't install insecurely without el-get-allow-insecure. 2014-08-12 11:42:08 -07:00
el-get-git.el Fix Git HTTP smart host detection (#2854) 2023-01-01 13:31:18 +01:00
el-get-github-tar.el Cleanup indentation with custom indent rules 2014-03-01 16:19:46 -08:00
el-get-github-zip.el Cleanup indentation with custom indent rules 2014-03-01 16:19:46 -08:00
el-get-github.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
el-get-go.el Fix missing requirements 2021-06-13 16:03:08 +02:00
el-get-hg.el Don't install insecurely without el-get-allow-insecure. 2014-08-12 11:42:08 -07:00
el-get-http-tar.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
el-get-http-zip.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
el-get-http.el el-get-http-install: allow for non-http urls 2015-10-27 20:12:20 -04:00
el-get-pacman.el el-get-executable-find: use it consistently 2015-07-27 14:56:02 -04:00
el-get-svn.el Don't install insecurely without el-get-allow-insecure. 2014-08-12 11:42:08 -07:00