diff options
author | Luca <ldanzelmo@gmail.com> | 2015-06-26 09:24:58 +0200 |
---|---|---|
committer | Luca <ldanzelmo@gmail.com> | 2015-06-26 09:24:58 +0200 |
commit | c687e2b9d2fefa362990f6f608c59c92a2575a3d (patch) | |
tree | ba6cf0d16bfe029ecce8961b2d1d9eb06dc6e258 | |
parent | 32ec7f2f5fb3e777fcb9730571c34633bfa5bcfb (diff) | |
download | Nim-c687e2b9d2fefa362990f6f608c59c92a2575a3d.tar.gz |
Allow ftp client to handle 220 multiline messages
-rw-r--r-- | lib/pure/ftpclient.nim | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/pure/ftpclient.nim b/lib/pure/ftpclient.nim index dd141eb01..7ede6b479 100644 --- a/lib/pure/ftpclient.nim +++ b/lib/pure/ftpclient.nim @@ -263,8 +263,18 @@ proc connect*[T](ftp: FtpBase[T]) = else: {.fatal: "Incorrect socket instantiation".} - # TODO: Handle 120? or let user handle it. - assertReply ftp.expectReply(), "220" + 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 + 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(ftp.send("USER " & ftp.user), "230", "331") |