Fix multiple issues when curl is not available and wget is used:
- Downloading JSON for the latest release results in HTTP 302 and wget
redirects to the new location. Read HTTP status only from the last
line of output else the code wouldn't match 200 even if the request
was successful.
- Don't set `--content-on-error` when using wget. It is of no
consequence since we are checking the HTTP status code and exit if the
response isn't 200 OK.
- `type` is undefined in POSIX sh, use `command` instead.
- Clean up the temp file.
Fixes#1728.