From 2787b571897469a912dee810a60a2dba5ea472af Mon Sep 17 00:00:00 2001 From: milarin Date: Tue, 7 Mar 2023 18:54:53 +0100 Subject: [PATCH] fixed curl problems again --- curl.go | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/curl.go b/curl.go index f3aa428..6f3b66a 100644 --- a/curl.go +++ b/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 {