1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ftp: protocol compatibility

This commit is contained in:
sha0coder 2020-01-19 13:53:13 +01:00 committed by Alexander Medvednikov
parent 3a8b437b8d
commit 990e44cd14

View File

@ -75,7 +75,7 @@ fn (ftp FTP) write(data string) ?int {
$if debug { $if debug {
println('FTP.v >>> $data') println('FTP.v >>> $data')
} }
n := ftp.sock.send_string('$data\n') or { n := ftp.sock.send_string('$data\r\n') or {
return error('Cannot send data') return error('Cannot send data')
} }
return n return n
@ -91,11 +91,11 @@ fn (ftp FTP) read() (int, string) {
return 0, '' return 0, ''
} }
code := data[0..3].int() code := data[..3].int()
if data[4] == `-` { if data[3] == `-` {
for { for {
data = ftp.sock.read_line() data = ftp.sock.read_line()
if data[0..3].int() == code { if data[..3].int() == code && data[3] != `-` {
break break
} }
} }