Merge pull request #201 from ncw/fix-200-FEAT

Delay FEAT command until after Login - fixes #200
This commit is contained in:
Julien Laffaye 2020-10-19 10:01:38 -04:00 committed by GitHub
commit 1344bef09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

19
ftp.go
View File

@ -135,16 +135,6 @@ func Dial(addr string, options ...DialOption) (*ServerConn, error) {
c.conn = textproto.NewConn(do.wrapConn(tconn)) c.conn = textproto.NewConn(do.wrapConn(tconn))
} }
err = c.feat()
if err != nil {
c.Quit()
return nil, err
}
if _, mlstSupported := c.features["MLST"]; mlstSupported {
c.mlstSupported = true
}
return c, nil return c, nil
} }
@ -282,6 +272,15 @@ func (c *ServerConn) Login(user, password string) error {
return errors.New(message) return errors.New(message)
} }
// Probe features
err = c.feat()
if err != nil {
return err
}
if _, mlstSupported := c.features["MLST"]; mlstSupported {
c.mlstSupported = true
}
// Switch to binary mode // Switch to binary mode
if _, _, err = c.cmd(StatusCommandOK, "TYPE I"); err != nil { if _, _, err = c.cmd(StatusCommandOK, "TYPE I"); err != nil {
return err return err