瀏覽代碼

Fix downloading

DarthSim 8 年之前
父節點
當前提交
838e549055
共有 2 個文件被更改,包括 7 次插入4 次删除
  1. 0 2
      README.md
  2. 7 2
      download.go

+ 0 - 2
README.md

@@ -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).

+ 7 - 2
download.go

@@ -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