1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00

Fix downloading

This commit is contained in:
DarthSim 2017-07-06 00:47:47 +06:00
parent d3f93f1a9a
commit 838e549055
2 changed files with 7 additions and 4 deletions

View File

@ -174,8 +174,6 @@ You can find helpful code snippets in the `examples` folder.
imgproxy supports only the three most popular image formats of the moment: PNG, JPEG, and GIF.
**Known issue:** `libvips` may not support some types of JPEG; if you stumble upon this issue, you may need to build `libvips` with ImageMagick or GraphicMagick support. See https://github.com/jcupitt/libvips#imagemagick-or-optionally-graphicsmagick
## Special thanks
Special thanks to [h2non](https://github.com/h2non) and all authors and contributors of [bimg](https://github.com/h2non/bimg).

View File

@ -1,6 +1,7 @@
package main
import (
"bufio"
"bytes"
"errors"
"fmt"
@ -20,13 +21,13 @@ var downloadClient = http.Client{
}
type netReader struct {
reader io.Reader
reader *bufio.Reader
buf *bytes.Buffer
}
func newNetReader(r io.Reader) *netReader {
return &netReader{
reader: r,
reader: bufio.NewReader(r),
buf: bytes.NewBuffer([]byte{}),
}
}
@ -39,6 +40,10 @@ func (r *netReader) Read(p []byte) (n int, err error) {
return
}
func (r *netReader) Peek(n int) ([]byte, error) {
return r.reader.Peek(n)
}
func (r *netReader) ReadAll() ([]byte, error) {
if _, err := r.buf.ReadFrom(r.reader); err != nil {
return []byte{}, err