USING: http http.server http.client tools.test multiline
-tuple-syntax io.streams.string io.encodings.utf8
-io.encodings.8-bit io.encodings.binary io.encodings.string
-kernel arrays splitting sequences assocs io.sockets db db.sqlite
-continuations urls hashtables accessors ;
+io.streams.string io.encodings.utf8 io.encodings.8-bit
+io.encodings.binary io.encodings.string kernel arrays splitting
+sequences assocs io.sockets db db.sqlite continuations urls
+hashtables accessors ;
IN: http.tests
[ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
;
[
- TUPLE{ request
- url: TUPLE{ url path: "/bar" }
- method: "POST"
- version: "1.1"
- header: H{ { "some-header" "1; 2" } { "content-length" "4" } { "content-type" "application/octet-stream" } }
- post-data: TUPLE{ post-data content: "blah" raw: "blah" content-type: "application/octet-stream" }
- cookies: V{ }
+ T{ request
+ { url T{ url { path "/bar" } } }
+ { method "POST" }
+ { version "1.1" }
+ { header H{ { "some-header" "1; 2" } { "content-length" "4" } { "content-type" "application/octet-stream" } } }
+ { post-data T{ post-data { content "blah" } { raw "blah" } { content-type "application/octet-stream" } } }
+ { cookies V{ } }
}
] [
read-request-test-1 lf>crlf [
;
[
- TUPLE{ request
- url: TUPLE{ url host: "www.sex.com" path: "/bar" }
- method: "HEAD"
- version: "1.1"
- header: H{ { "host" "www.sex.com" } }
- cookies: V{ }
+ T{ request
+ { url T{ url { host "www.sex.com" } { path "/bar" } } }
+ { method "HEAD" }
+ { version "1.1" }
+ { header H{ { "host" "www.sex.com" } } }
+ { cookies V{ } }
}
] [
read-request-test-2 lf>crlf [
;
[
- TUPLE{ response
- version: "1.1"
- code: 404
- message: "not found"
- header: H{ { "content-type" "text/html; charset=UTF-8" } }
- cookies: { }
- content-type: "text/html"
- content-charset: utf8
+ T{ response
+ { version "1.1" }
+ { code 404 }
+ { message "not found" }
+ { header H{ { "content-type" "text/html; charset=UTF-8" } } }
+ { cookies { } }
+ { content-type "text/html" }
+ { content-charset utf8 }
}
] [
read-response-test-1 lf>crlf
: add-quit-action
<action>
- [ stop-server "Goodbye" "text/html" <content> ] >>display
+ [ stop-this-server "Goodbye" "text/html" <content> ] >>display
"quit" add-responder ;
-: test-db "test.db" temp-file sqlite-db ;
+: test-db "test.db" temp-file <sqlite-db> ;
[ test-db drop delete-file ] ignore-errors
"" add-responder
add-quit-action
<dispatcher>
- <action> "a" add-main-responder
+ <action> "" add-responder
"d" add-responder
test-db <db-persistence>
main-responder set