Bladeren bron

Fix never succeeding read into empty buffer

The problem was that we set the capacity to one, but the length to zero,
which meant that `Read` could never put any data into the buffer,
returning zero, which meant that favicon thought there was no data.
Lucas Stadler 8 jaren geleden
bovenliggende
commit
26d2380974
1 gewijzigde bestanden met toevoegingen van 1 en 1 verwijderingen
  1. 1 1
      go/favicon/favicon.go

+ 1 - 1
go/favicon/favicon.go

@ -247,7 +247,7 @@ func GetCanonicalFavicon(u string) (string, error) {
247 247
	if resp.StatusCode >= 400 || resp.Header.Get("Content-Length") == "0" {
248 248
		return "", errors.New("no /favicon.ico")
249 249
	}
250
	buf := make([]byte, 0, 1)
250
	buf := make([]byte, 1)
251 251
	n, err := resp.Body.Read(buf)
252 252
	if err != nil || n == 0 {
253 253
		return "", errors.New("can't read /favicon.ico")