-USING: kernel furnace.actions validators tools.test math math.parser
+USING: kernel furnace.actions io.crlf validators tools.test math math.parser
multiline namespaces http io.streams.string http.server http.server.requests
sequences splitting accessors ;
IN: furnace.actions.tests
[ "a" param "b" param [ string>number ] bi@ + ] >>display
"action-1" set
-: lf>crlf ( string -- string' ) "\n" split "\r\n" join ;
-
STRING: action-request-test-1
GET http://foo/bar?a=12&b=13 HTTP/1.1
USING: destructors http http.server http.server.requests http.client
-http.client.private tools.test multiline fry io.streams.string io.encodings.utf8
-io.encodings.8-bit io.encodings.binary io.encodings.string io.encodings.ascii
-kernel arrays splitting sequences assocs io.sockets db db.sqlite make
-continuations urls hashtables accessors namespaces xml.data
+http.client.private tools.test multiline fry io.streams.string io.crlf
+io.encodings.utf8 io.encodings.8-bit io.encodings.binary io.encodings.string
+io.encodings.ascii kernel arrays splitting sequences assocs io.sockets db
+db.sqlite make continuations urls hashtables accessors namespaces xml.data
io.encodings.8-bit.latin1 random combinators.short-circuit ;
IN: http.tests
[ "localhost:8080" ] [ T{ url { protocol "http" } { host "localhost" } { port 8080 } } unparse-host ] unit-test
[ "localhost:8443" ] [ T{ url { protocol "https" } { host "localhost" } { port 8443 } } unparse-host ] unit-test
-: lf>crlf ( string -- string' ) "\n" split "\r\n" join ;
-
STRING: read-request-test-1
POST /bar HTTP/1.1
Some-Header: 1
USING: accessors assocs continuations http http.client http.client.private
-http.server http.server.requests io.streams.limited io.streams.string kernel
-math math.parser multiline namespaces peg sequences splitting tools.test urls ;
+http.server http.server.requests io.crlf io.streams.limited io.streams.string
+kernel math math.parser multiline namespaces peg sequences splitting
+tools.test urls ;
IN: http.server.requests.tests
-: normalize-nl ( str -- str' )
- "\n" "\r\n" replace ;
-
: request>string ( request -- string )
[ write-request ] with-string-writer ;
"form-data; name=\"text\"; filename=\"upload.txt\"" }
}
} [
- test-multipart/form-data normalize-nl string>request
+ test-multipart/form-data lf>crlf string>request
post-data>> params>> "text" of [ filename>> ] [ headers>> ] bi
] unit-test
{ redirects 10 }
}
] [
- "\r\n\r\n\r\nGET / HTTP/1.0\r\n\r\n"
- [ read-request ] with-string-reader
+ "\r\n\r\n\r\nGET / HTTP/1.0\r\n\r\n" [ read-request ] with-string-reader
] unit-test
! RFC 2616: Section 19.3
"host: 127.0.0.1:55532"
"user-agent: Factor http.client"
} [ "\n" join ] [ "\r\n" join ] bi
- [ [ read-request ] with-string-reader ] same?
+ [ string>request ] same?
] unit-test
[ f ] [ "" [ read-?crlf ] with-string-reader ] unit-test
[ "" ] [ "\n" [ read-?crlf ] with-string-reader ] unit-test
[ "foo" ] [ "foo\n" [ read-?crlf ] with-string-reader ] unit-test
+
+[ "foo\nbar" ] [ "foo\n\rbar" crlf>lf ] unit-test
+[ "foo\r\nbar" ] [ "foo\nbar" lf>crlf ] unit-test
! Copyright (C) 2009 Daniel Ehrenberg, Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
-USING: io kernel sequences ;
+USING: io kernel sequences splitting ;
IN: io.crlf
: crlf ( -- )
: read-?crlf ( -- seq )
"\r\n" read-until
[ CHAR: \r = [ read1 CHAR: \n assert= ] when ] [ f like ] if* ;
+
+: crlf>lf ( str -- str' )
+ CHAR: \r swap remove ;
+
+: lf>crlf ( str -- str' )
+ "\n" split "\r\n" join ;
windows.messages windows.types windows.offscreen windows threads
libc combinators fry combinators.short-circuit continuations
command-line shuffle opengl ui.render math.bitwise locals
-accessors math.rectangles math.order calendar ascii sets
+accessors math.rectangles math.order calendar ascii sets io.crlf
io.encodings.utf16n windows.errors literals ui.pixel-formats
ui.pixel-formats.private memoize classes colors
specialized-arrays classes.struct ;
: GET_APPCOMMAND_LPARAM ( lParam -- appCommand )
hi-word FAPPCOMMAND_MASK lo-word bitnot bitand ; inline
-: crlf>lf ( str -- str' )
- CHAR: \r swap remove ;
-
-: lf>crlf ( str -- str' )
- [ [ dup CHAR: \n = [ CHAR: \r , ] when , ] each ] "" make ;
-
: enum-clipboard ( -- seq )
0
[ EnumClipboardFormats win32-error dup dup 0 > ]
EmptyClipboard win32-error=0/f
GMEM_MOVEABLE over length 1 + GlobalAlloc
dup win32-error=0/f
-
+
dup GlobalLock dup win32-error=0/f
rot binary-object memcpy
dup GlobalUnlock win32-error=0/f
{ APPCOMMAND_BROWSER_FORWARD [ pick window right-action send-action ] }
[ drop ]
} case 3drop ;
-
+
: handle-wm-buttondown ( hWnd uMsg wParam lParam -- )
[
over set-capture
4drop release-capture ;
: handle-wm-mouseleave ( hWnd uMsg wParam lParam -- )
- #! message sent if mouse leaves main application
+ #! message sent if mouse leaves main application
4drop forget-rollover ;
: system-background-color ( -- color )
t ;
windows-ui-backend ui-backend set-global
-