diff options
author | Luca <ldanzelmo@gmail.com> | 2015-06-26 09:18:40 +0200 |
---|---|---|
committer | Luca <ldanzelmo@gmail.com> | 2015-06-26 09:18:40 +0200 |
commit | 32ec7f2f5fb3e777fcb9730571c34633bfa5bcfb (patch) | |
tree | b51f0077d84c57f78b6955c7f550125adec3a743 | |
parent | afad61c220280ef6ab6362dc5cadbab8ab0b20fc (diff) | |
download | Nim-32ec7f2f5fb3e777fcb9730571c34633bfa5bcfb.tar.gz |
Allow AsyncFtpClient and ftpclient to check 220 messages
As many ftp servers can answer with multiple 220 messages these two libraries have to handle multiline 220 messages before send user and pass messages.
-rw-r--r-- | lib/pure/asyncftpclient.nim | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pure/asyncftpclient.nim b/lib/pure/asyncftpclient.nim index daf69d59f..c3545ada8 100644 --- a/lib/pure/asyncftpclient.nim +++ b/lib/pure/asyncftpclient.nim @@ -79,7 +79,13 @@ proc connect*(ftp: AsyncFtpClient) {.async.} = # 120 Service ready in nnn minutes. # We wait until we receive 220. reply = await ftp.expectReply() - assertReply(reply, "220") + + # Handle 220 messages from the server + if reply.startsWith("220"): + assertReply(reply, "220") + while reply.continuesWith("-", 3): # handle multiline 220 message + assertReply(reply, "220") + reply = await ftp.expectReply() if ftp.user != "": assertReply(await(ftp.send("USER " & ftp.user)), "230", "331") |