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.
This commit is contained in:
Luca
2015-06-26 09:18:40 +02:00
parent afad61c220
commit 32ec7f2f5f

View File

@@ -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")