Browse Source

Make GetArchiveLink behave the same as other calls

All available calls in the `go-github` package close the `resp.Body` before returning.

Because the `GetArchiveLink` method doesn’t use the [`Do`](https://github.com/google/go-github/blob/master/github/github.go#L381) method, we have to make sure the body is closed here as well.

Closes #485.

Change-Id: Iec0d88cf66d4d658fcd6aec374b4bc2358269a09
Sander van Harmelen 9 years ago
committed by Glenn Lewis
parent
commit
466070b058
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      github/repos_contents.go

+ 6
- 2
github/repos_contents.go View File

@ -267,8 +267,12 @@ func (s *RepositoriesService) GetArchiveLink(owner, repo string, archiveformat a
} else {
resp, err = s.client.client.Transport.RoundTrip(req)
}
if err != nil || resp.StatusCode != http.StatusFound {
return nil, newResponse(resp), err
if err != nil {
return nil, nil, err
}
resp.Body.Close()
if resp.StatusCode != http.StatusFound {
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
}
parsedURL, err := url.Parse(resp.Header.Get("Location"))
return parsedURL, newResponse(resp), err


Loading…
Cancel
Save