It's easy to access github private resources later through specific `header` settings.
e.g.
```
cask 'XXXX' do
...
url "https://raw.githubusercontent.com/....",
header : "Authorization: token #{ENV['HOMEBREW_GITHUB_API_TOKEN']}"
...
end
```
Instead of only looking at the extension when invoked as part of
Homebrew's formulae' download strategies instead prioritise the
extension if it actually exists. When it does not, fall back to the
magic detection logic which is likely to be more reliable.
Fixes https://github.com/Homebrew/brew/issues/5895
Fixes#5357
* Eliminates getting a new strategy instance via Resource methods
* only call resolve_url_basename_time once and store the time result as
an instance variable for reuse
This issue causes method in a Nil object to be read when a mirror download fails. In my case, this occurs due to my office's proxy blocking certain mirrors. This patch fixes the Nil access, exposing a more helpful error message.
## Before patch
```
$ brew install maven
Error: An exception occurred within a child process:
NoMethodError: undefined method `unlock' for nil:NilClass
```
## After patch
```
$ brew install maven
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "maven"
Download failed: Couldn't determine mirror, try again later.
```
## Steps to reproduce
1. Use brew 1.8.0
2. Ensure maven is not installed:
```
brew remove maven
```
3. Ensure the download is not cached:
```
rm "$HOME/Library/Caches/Homebrew/downloads/*--apache-maven-*-bin.tar.gz"
```
4. Make the mirrors unreachable by pointing them at a nonfunctional proxy:
```
export http{,s}_proxy=http://localhost:8080
export no_proxy=*.github.com,*.brew.sh
```
5. Attempt package installation
```
brew install maven
```
Download the unused, private download strategies. These are a better fit
for being declared in the formulae and/or taps that use them rather than
in Homebrew/brew where they are unused by Homebrew maintainers or
official taps/formulae.
Use 124 max line length everywhere. Also, reduce tap max line length to
189 as Homebrew/homebrew-core has that as a maximum now. In future
Homebrew/homebrew-core will also be reduced to 124 maximum line length.
528b4b367ed2a4026c321e2f2e503ace4548b9d2 moved the chdir definition to
the parent class and call it in the parent's stage. chdir was getting
called twice for archives with two nested directories.