Factored out io.crlf
parent
69c509a29f
commit
fcb56cf6db
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: combinators io io.binary io.encodings.binary
|
USING: combinators io io.binary io.encodings.binary
|
||||||
io.streams.byte-array io.streams.string kernel math namespaces
|
io.streams.byte-array io.streams.string kernel math namespaces
|
||||||
sequences strings ;
|
sequences strings io.crlf ;
|
||||||
IN: base64
|
IN: base64
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -32,7 +32,7 @@ SYMBOL: column
|
||||||
: write1-lines ( ch -- )
|
: write1-lines ( ch -- )
|
||||||
write1
|
write1
|
||||||
column get [
|
column get [
|
||||||
1+ [ 76 = [ "\r\n" write ] when ]
|
1+ [ 76 = [ crlf ] when ]
|
||||||
[ 76 mod column set ] bi
|
[ 76 mod column set ] bi
|
||||||
] when* ;
|
] when* ;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ quotations arrays byte-arrays math.parser calendar
|
||||||
calendar.format present urls
|
calendar.format present urls
|
||||||
|
|
||||||
io io.encodings io.encodings.iana io.encodings.binary
|
io io.encodings io.encodings.iana io.encodings.binary
|
||||||
io.encodings.8-bit
|
io.encodings.8-bit io.crlf
|
||||||
|
|
||||||
unicode.case unicode.categories
|
unicode.case unicode.categories
|
||||||
|
|
||||||
|
@ -16,12 +16,6 @@ EXCLUDE: fry => , ;
|
||||||
|
|
||||||
IN: http
|
IN: http
|
||||||
|
|
||||||
: crlf ( -- ) "\r\n" write ;
|
|
||||||
|
|
||||||
: read-crlf ( -- bytes )
|
|
||||||
"\r" read-until
|
|
||||||
[ CHAR: \r assert= read1 CHAR: \n assert= ] when* ;
|
|
||||||
|
|
||||||
: (read-header) ( -- alist )
|
: (read-header) ( -- alist )
|
||||||
[ read-crlf dup f like ] [ parse-header-line ] [ drop ] produce ;
|
[ read-crlf dup f like ] [ parse-header-line ] [ drop ] produce ;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
! Copyright (C) 2009 Daniel Ehrenberg
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: help.syntax help.markup sequences ;
|
||||||
|
IN: io.crlf
|
||||||
|
|
||||||
|
HELP: crlf
|
||||||
|
{ $values }
|
||||||
|
{ $description "Prints a carriage return and line feed to the current output stream, used to indicate a newline for certain network protocols." } ;
|
||||||
|
|
||||||
|
HELP: read-crlf
|
||||||
|
{ $values { "seq" sequence } }
|
||||||
|
{ $description "Reads until the next CRLF (carriage return followed by line feed) from the current input stream, throwing an error if there is not a CRLF remaining, or if CR is present without immediately being followed by LF." } ;
|
|
@ -0,0 +1,11 @@
|
||||||
|
! Copyright (C) 2009 Daniel Ehrenberg, Slava Pestov
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: io kernel ;
|
||||||
|
IN: io.crlf
|
||||||
|
|
||||||
|
: crlf ( -- )
|
||||||
|
"\r\n" write ;
|
||||||
|
|
||||||
|
: read-crlf ( -- seq )
|
||||||
|
"\r" read-until
|
||||||
|
[ CHAR: \r assert= read1 CHAR: \n assert= ] when* ;
|
|
@ -4,7 +4,7 @@ USING: combinators kernel prettyprint io io.timeouts sequences
|
||||||
namespaces io.sockets io.sockets.secure continuations calendar
|
namespaces io.sockets io.sockets.secure continuations calendar
|
||||||
io.encodings.ascii io.streams.duplex destructors locals
|
io.encodings.ascii io.streams.duplex destructors locals
|
||||||
concurrency.promises threads accessors smtp.private
|
concurrency.promises threads accessors smtp.private
|
||||||
io.sockets.secure.unix.debug ;
|
io.sockets.secure.unix.debug io.crlf ;
|
||||||
IN: smtp.server
|
IN: smtp.server
|
||||||
|
|
||||||
! Mock SMTP server for testing purposes.
|
! Mock SMTP server for testing purposes.
|
||||||
|
|
|
@ -6,7 +6,7 @@ io.encodings.utf8 io.timeouts io.sockets io.sockets.secure
|
||||||
io.encodings.ascii kernel logging sequences combinators
|
io.encodings.ascii kernel logging sequences combinators
|
||||||
splitting assocs strings math.order math.parser random system
|
splitting assocs strings math.order math.parser random system
|
||||||
calendar summary calendar.format accessors sets hashtables
|
calendar summary calendar.format accessors sets hashtables
|
||||||
base64 debugger classes prettyprint ;
|
base64 debugger classes prettyprint io.crlf ;
|
||||||
IN: smtp
|
IN: smtp
|
||||||
|
|
||||||
SYMBOL: smtp-domain
|
SYMBOL: smtp-domain
|
||||||
|
@ -50,12 +50,6 @@ TUPLE: email
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: crlf ( -- ) "\r\n" write ;
|
|
||||||
|
|
||||||
: read-crlf ( -- bytes )
|
|
||||||
"\r" read-until
|
|
||||||
[ CHAR: \r assert= read1 CHAR: \n assert= ] when* ;
|
|
||||||
|
|
||||||
: command ( string -- ) write crlf flush ;
|
: command ( string -- ) write crlf flush ;
|
||||||
|
|
||||||
\ command DEBUG add-input-logging
|
\ command DEBUG add-input-logging
|
||||||
|
|
Loading…
Reference in New Issue