 
 : handle-USER ( ftp-command -- )
     [
-        drop
+        tokenized>> second client get (>>user)
         331 "Please specify the password." server-response
     ] [
         2drop "bad USER" ftp-error

unicode.case splitting assocs classes io.servers.connection
destructors calendar io.timeouts io.streams.duplex threads
continuations math concurrency.promises byte-arrays
io.backend sequences.lib tools.hexdump io.files.listing ;
IN: ftp.server

TUPLE: ftp-client url mode state command-promise ;

: <ftp-client> ( url -- ftp-client )
    ftp-client new

    150 "Here comes the directory listing." server-response ;

: finish-directory ( -- )
    226 "Directory send OK." server-response ;

GENERIC: service-command ( stream obj -- )

M: ftp-list service-command ( stream obj -- )
    drop
    start-directory [
        utf8 encode-output
        [ current-directory get directory. ] with-string-writer string-lines
        harvest [ ftp-send ] each
    ] with-output-stream
    finish-directory ;

