From 2257d14f75b44e9b2362be97f396c2fa91a8aaeb Mon Sep 17 00:00:00 2001 From: Julien Laffaye Date: Sun, 19 May 2013 21:23:29 +0200 Subject: [PATCH] Use ReadResponse instead of ReadCodeLine. ReadResponse deals with multi-lines reponse, ReadCodeLine does not. While I'm here, use the cmd() helper in epsv() method. --- ftp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftp.go b/ftp.go index ccfa08b..2c9725e 100644 --- a/ftp.go +++ b/ftp.go @@ -88,11 +88,11 @@ func (c *ServerConn) Login(user, password string) error { // epsv issues an "EPSV" command to get a port number for a data connection. func (c *ServerConn) epsv() (port int, err error) { - c.conn.Cmd("EPSV") - _, line, err := c.conn.ReadCodeLine(StatusExtendedPassiveMode) + _, line, err := c.cmd(StatusExtendedPassiveMode, "EPSV") if err != nil { return } + start := strings.Index(line, "|||") end := strings.LastIndex(line, "|") if start == -1 || end == -1 { @@ -132,7 +132,7 @@ func (c *ServerConn) cmd(expected int, format string, args ...interface{}) (int, return 0, "", err } - code, line, err := c.conn.ReadCodeLine(expected) + code, line, err := c.conn.ReadResponse(expected) return code, line, err }