Making with-server take encodings properly

db4
Daniel Ehrenberg 2008-02-25 15:10:14 -06:00
parent 63e04a9b17
commit 278509336d
5 changed files with 13 additions and 13 deletions

View File

@ -1,9 +1,9 @@
USING: io.sockets io.server io kernel math threads USING: io.sockets io.server io kernel math threads io.encodings.ascii
debugger tools.time prettyprint concurrency.combinators ; debugger tools.time prettyprint concurrency.combinators ;
IN: benchmark.sockets IN: benchmark.sockets
: simple-server ( -- ) : simple-server ( -- )
7777 local-server "benchmark.sockets" [ 7777 local-server "benchmark.sockets" ascii [
read1 CHAR: x = [ read1 CHAR: x = [
stop-server stop-server
] [ ] [

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: serialize sequences concurrency.messaging USING: serialize sequences concurrency.messaging
threads io io.server qualified arrays threads io io.server qualified arrays
namespaces kernel ; namespaces kernel io.encodings.binary ;
QUALIFIED: io.sockets QUALIFIED: io.sockets
IN: concurrency.distributed IN: concurrency.distributed
@ -15,7 +15,7 @@ SYMBOL: local-node ( -- addrspec )
[ [
local-node set-global local-node set-global
"concurrency.distributed" "concurrency.distributed"
[ handle-node-client ] with-server binary [ handle-node-client ] with-server
] 2curry f spawn drop ; ] 2curry f spawn drop ;
: start-node ( port -- ) : start-node ( port -- )

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: assocs kernel namespaces io io.timeouts strings splitting USING: assocs kernel namespaces io io.timeouts strings splitting
threads http http.server.responders sequences prettyprint threads http http.server.responders sequences prettyprint
io.server logging calendar ; io.server logging calendar io.encodings.latin1 ;
IN: http.server IN: http.server
@ -49,7 +49,7 @@ IN: http.server
\ parse-request NOTICE add-input-logging \ parse-request NOTICE add-input-logging
: httpd ( port -- ) : httpd ( port -- )
internet-server "http.server" [ internet-server "http.server" latin1 [
1 minutes stdio get set-timeout 1 minutes stdio get set-timeout
readln [ parse-request ] when* readln [ parse-request ] when*
] with-server ; ] with-server ;

View File

@ -44,12 +44,12 @@ PRIVATE>
: internet-server ( port -- seq ) : internet-server ( port -- seq )
f swap t resolve-host ; f swap t resolve-host ;
: with-server ( seq service quot -- ) : with-server ( seq service encoding quot -- )
V{ } clone [ V{ } clone [
servers [ swap servers [
[ server-loop ] curry with-logging [ server-loop ] 2curry with-logging
] with-variable ] with-variable
] 3curry parallel-each ; inline ] 3curry curry parallel-each ; inline
: stop-server ( -- ) : stop-server ( -- )
servers get [ dispose ] each ; servers get [ dispose ] each ;

View File

@ -1,10 +1,10 @@
USING: listener io.server ; USING: listener io.server io.encodings.utf8 ;
IN: tty-server IN: tty-server
: tty-server ( port -- ) : tty-server ( port -- )
local-server local-server
"tty-server" "tty-server"
[ listener ] with-server ; utf8 [ listener ] with-server ;
: default-tty-server 9999 tty-server ; : default-tty-server 9999 tty-server ;