diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-15 03:51:04 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-15 03:51:04 +0200 |
commit | bcb49927a3897eadc29960032c70da29e26d6b58 (patch) | |
tree | 60025a0a59d15e49c6027b1bfd5d6fee5d5d2438 /clients/http/git_upload_pack.go | |
parent | f6fe29c80d11662a169806dcf413ecdedcb28fa3 (diff) | |
download | go-git-bcb49927a3897eadc29960032c70da29e26d6b58.tar.gz |
Repository.Clone and Remote.Fetch remote, local branches and client: correct header read
Diffstat (limited to 'clients/http/git_upload_pack.go')
-rw-r--r-- | clients/http/git_upload_pack.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/clients/http/git_upload_pack.go b/clients/http/git_upload_pack.go index 96535de..68ec238 100644 --- a/clients/http/git_upload_pack.go +++ b/clients/http/git_upload_pack.go @@ -66,14 +66,28 @@ func (s *GitUploadPackService) Fetch(r *common.GitUploadPackRequest) (io.ReadClo return nil, err } - h := make([]byte, 8) - if _, err := res.Body.Read(h); err != nil { - return nil, core.NewUnexpectedError(err) + if err := s.discardResponseInfo(res.Body); err != nil { + return nil, err } return res.Body, nil } +func (s *GitUploadPackService) discardResponseInfo(r io.Reader) error { + decoder := pktline.NewDecoder(r) + for { + line, err := decoder.ReadLine() + if err != nil { + break + } + + if line == "NAK\n" { + break + } + } + + return nil +} func (s *GitUploadPackService) doRequest(method, url string, content *strings.Reader) (*http.Response, error) { var body io.Reader if content != nil { |