Browse Source

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.
Julien Laffaye 12 years ago
parent
commit
2257d14f75
1 changed files with 3 additions and 3 deletions
  1. 3 3
      ftp.go

+ 3 - 3
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
 }