mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 08:14:15 +00:00
fix: Response body was not closed causing the goroutine leak
This commit is contained in:
parent
db966a275c
commit
e0764c06a3
41
client.go
41
client.go
@ -193,8 +193,13 @@ func (c *Client) Create(name string) (io.WriteCloser, error) {
|
||||
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
_, err := c.ic.Do(req)
|
||||
done <- err
|
||||
resp, err := c.ic.Do(req)
|
||||
if err != nil {
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
resp.Body.Close()
|
||||
done <- nil
|
||||
}()
|
||||
|
||||
return &fileWriter{pw, done}, nil
|
||||
@ -206,8 +211,12 @@ func (c *Client) RemoveAll(name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.ic.Do(req)
|
||||
return err
|
||||
resp, err := c.ic.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Mkdir(name string) error {
|
||||
@ -216,8 +225,12 @@ func (c *Client) Mkdir(name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.ic.Do(req)
|
||||
return err
|
||||
resp, err := c.ic.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) CopyAll(name, dest string, overwrite bool) error {
|
||||
@ -229,8 +242,12 @@ func (c *Client) CopyAll(name, dest string, overwrite bool) error {
|
||||
req.Header.Set("Destination", c.ic.ResolveHref(dest).String())
|
||||
req.Header.Set("Overwrite", internal.FormatOverwrite(overwrite))
|
||||
|
||||
_, err = c.ic.Do(req)
|
||||
return err
|
||||
resp, err := c.ic.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) MoveAll(name, dest string, overwrite bool) error {
|
||||
@ -242,6 +259,10 @@ func (c *Client) MoveAll(name, dest string, overwrite bool) error {
|
||||
req.Header.Set("Destination", c.ic.ResolveHref(dest).String())
|
||||
req.Header.Set("Overwrite", internal.FormatOverwrite(overwrite))
|
||||
|
||||
_, err = c.ic.Do(req)
|
||||
return err
|
||||
resp, err := c.ic.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user