chore(grequests): update grequests to v2
This commit is contained in:
parent
a88da88a47
commit
00bf1820f1
5 changed files with 18 additions and 13 deletions
|
@ -1,13 +1,14 @@
|
|||
package downloader
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
req "github.com/levigross/grequests"
|
||||
req "github.com/levigross/grequests/v2"
|
||||
"github.com/schollz/progressbar/v3"
|
||||
)
|
||||
|
||||
|
@ -29,8 +30,8 @@ func NewContext(filename, link string) *Context {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *Context) Download() error {
|
||||
resp, err := req.Head(c.Link, nil)
|
||||
func (c *Context) Download(ctx context.Context) error {
|
||||
resp, err := req.Head(ctx, c.Link)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no such host") {
|
||||
return ErrInvalidURL
|
||||
|
@ -54,7 +55,7 @@ func (c *Context) Download() error {
|
|||
return errors.New(resp.RawResponse.Status)
|
||||
}
|
||||
|
||||
resp, err = req.Get(c.Link, nil)
|
||||
resp, err = req.Get(ctx, c.Link)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue