From 32ec7f2f5fb3e777fcb9730571c34633bfa5bcfb Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 26 Jun 2015 09:18:40 +0200 Subject: [PATCH] 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. --- lib/pure/asyncftpclient.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pure/asyncftpclient.nim b/lib/pure/asyncftpclient.nim index daf69d59f5..c3545ada8c 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")