do ReadCodeLine in Close() @ ReadCloser
This commit is contained in:
parent
60f85a4eb0
commit
65a25a2848
@ -57,6 +57,13 @@ func TestConn(t *testing.T) {
|
||||
r.Close()
|
||||
}
|
||||
|
||||
r, err = c.Retr("tset")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
r.Close()
|
||||
}
|
||||
|
||||
err = c.Delete("tset")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
14
ftp.go
14
ftp.go
@ -405,16 +405,16 @@ func (c *ServerConn) Quit() error {
|
||||
// Read implements the io.Reader interface on a FTP data connection.
|
||||
func (r *response) Read(buf []byte) (int, error) {
|
||||
n, err := r.conn.Read(buf)
|
||||
if err == io.EOF {
|
||||
_, _, err2 := r.c.conn.ReadCodeLine(StatusClosingDataConnection)
|
||||
if err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
// Close implements the io.Closer interface on a FTP data connection.
|
||||
func (r *response) Close() error {
|
||||
return r.conn.Close()
|
||||
err := r.conn.Close()
|
||||
_, _, err2 := r.c.conn.ReadCodeLine(StatusClosingDataConnection)
|
||||
if err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user