Skip to content

Commit

Permalink
Merge pull request jlaffaye#66 from zeast/master
Browse files Browse the repository at this point in the history
use utf8 default
  • Loading branch information
jlaffaye authored Jan 20, 2017
2 parents 0757556 + bb08d64 commit 5a8b8ee
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func DialTimeout(addr string, timeout time.Duration) (*ServerConn, error) {
return nil, err
}

err = c.setUTF8()
if err != nil {
c.Quit()
return nil, err
}

return c, nil
}

Expand Down Expand Up @@ -164,6 +170,24 @@ func (c *ServerConn) feat() error {
return nil
}

// setUTF8 issues an "OPTS UTF8 ON" command.
func (c *ServerConn) setUTF8() error {
if _, ok := c.features["UTF8"]; !ok {
return nil
}

code, message, err := c.cmd(-1, "OPTS UTF8 ON")
if err != nil {
return err
}

if code != StatusCommandOK {
return errors.New(message)
}

return nil
}

// epsv issues an "EPSV" command to get a port number for a data connection.
func (c *ServerConn) epsv() (port int, err error) {
_, line, err := c.cmd(StatusExtendedPassiveMode, "EPSV")
Expand Down

0 comments on commit 5a8b8ee

Please sign in to comment.