mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2026-11-22 22:48:59 +01:00
satisfy linter
This commit is contained in:
11
fetch.go
11
fetch.go
@@ -41,6 +41,7 @@ type Fetcher struct {
|
||||
// Pos is a counter for debug output file names
|
||||
type Pos struct {
|
||||
sync.Mutex
|
||||
|
||||
pos int
|
||||
}
|
||||
|
||||
@@ -98,7 +99,9 @@ func (f *Fetcher) Get(uri string) (io.ReadCloser, error) {
|
||||
slog.Debug("got cookies?", "cookies", res.Cookies())
|
||||
f.Cookies = res.Cookies()
|
||||
|
||||
f.Dump(res)
|
||||
if err := f.Dump(res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res.Body, nil
|
||||
}
|
||||
@@ -110,18 +113,22 @@ func (f *Fetcher) Dump(res *http.Response) error {
|
||||
defer pos.Unlock()
|
||||
|
||||
pos.pos++
|
||||
|
||||
dump, err := httputil.DumpResponse(res, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file := fmt.Sprintf("out%d.html", pos.pos)
|
||||
|
||||
fd, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fd.Write(dump)
|
||||
if _, err := fd.Write(dump); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
slog.Debug("dump content", "file", file)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user