diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-07-01 19:25:07 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-07-01 19:25:07 +0100 |
commit | d67e93340a30060fc7d2088f7d2e11d17079a83d (patch) | |
tree | ba0a66c03884ae341bdfdefeae85df678155c766 | |
parent | 0d7e0e1b4fb9e99259eb9f2a1ad42a7c0136e48b (diff) | |
parent | 110d84a9167ad077bb8ca983c43c8febc5780cc6 (diff) | |
download | Nim-d67e93340a30060fc7d2088f7d2e11d17079a83d.tar.gz |
Merge branch 'patch-1' of https://github.com/acidvertigo/Nim into acidvertigo-patch-1
-rw-r--r-- | lib/pure/asyncftpclient.nim | 5 | ||||
-rw-r--r-- | lib/pure/ftpclient.nim | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/pure/asyncftpclient.nim b/lib/pure/asyncftpclient.nim index daf69d59f..ff98d94c1 100644 --- a/lib/pure/asyncftpclient.nim +++ b/lib/pure/asyncftpclient.nim @@ -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") diff --git a/lib/pure/ftpclient.nim b/lib/pure/ftpclient.nim index dd141eb01..2644fc010 100644 --- a/lib/pure/ftpclient.nim +++ b/lib/pure/ftpclient.nim @@ -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") |