Merge branch 'patch-1' of https://github.com/acidvertigo/Nim into acidvertigo-patch-1

This commit is contained in:
Dominik Picheta
2015-07-01 19:25:07 +01:00
2 changed files with 15 additions and 1 deletions

View File

@@ -79,7 +79,12 @@ proc connect*(ftp: AsyncFtpClient) {.async.} =
# 120 Service ready in nnn minutes.
# We wait until we receive 220.
reply = await ftp.expectReply()
# Handle 220 messages from the server
assertReply(reply, "220")
while reply[3] == "-": # handle multiline 220 message
assertReply(reply, "220")
reply = await ftp.expectReply()
if ftp.user != "":
assertReply(await(ftp.send("USER " & ftp.user)), "230", "331")

View File

@@ -263,8 +263,17 @@ proc connect*[T](ftp: FtpBase[T]) =
else:
{.fatal: "Incorrect socket instantiation".}
# TODO: Handle 120? or let user handle it.
var reply = ftp.expectReply()
if reply.startsWith("120"):
# 120 Service ready in nnn minutes.
# We wait until we receive 220.
reply = ftp.expectReply()
# Handle 220 messages from the server
assertReply ftp.expectReply(), "220"
while reply[3] == "-": # handle multiline 220 message
assertReply ftp.expectReply(), "220"
reply = ftp.expectReply()
if ftp.user != "":
assertReply(ftp.send("USER " & ftp.user), "230", "331")