fixed curl problems again
This commit is contained in:
parent
799d8d5dee
commit
2787b57189
29
curl.go
29
curl.go
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"git.milar.in/milarin/adverr"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
@ -26,23 +25,11 @@ func (api *Api) GetWithCookie(ctx context.Context, url string) (*goquery.Documen
|
||||
if err != nil {
|
||||
return nil, ErrCurlRequestFailed.Wrap(err, url)
|
||||
}
|
||||
defer stdout.Close()
|
||||
|
||||
stderr, err := curl.StderrPipe()
|
||||
if err != nil {
|
||||
return nil, ErrCurlRequestFailed.Wrap(err, url)
|
||||
}
|
||||
defer stderr.Close()
|
||||
|
||||
if err := curl.Start(); err != nil {
|
||||
return nil, ErrCurlRequestFailed.Wrap(err, url)
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := curl.Wait(); err != nil {
|
||||
adverr.Println(ErrCurlRequestFailed.Wrap(err, url))
|
||||
}
|
||||
}()
|
||||
defer curl.Wait()
|
||||
|
||||
r, err := gzip.NewReader(stdout)
|
||||
if err != nil {
|
||||
@ -63,23 +50,11 @@ func (api *Api) Get(ctx context.Context, url string) (*goquery.Document, error)
|
||||
if err != nil {
|
||||
return nil, ErrCurlRequestFailed.Wrap(err, url)
|
||||
}
|
||||
defer stdout.Close()
|
||||
|
||||
stderr, err := curl.StderrPipe()
|
||||
if err != nil {
|
||||
return nil, ErrCurlRequestFailed.Wrap(err, url)
|
||||
}
|
||||
defer stderr.Close()
|
||||
|
||||
if err := curl.Start(); err != nil {
|
||||
return nil, ErrCurlRequestFailed.Wrap(err, url)
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := curl.Wait(); err != nil {
|
||||
adverr.Println(ErrCurlRequestFailed.Wrap(err, url))
|
||||
}
|
||||
}()
|
||||
defer curl.Wait()
|
||||
|
||||
r, err := gzip.NewReader(stdout)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user