io.encodings.8-bit.latin1 random combinators.short-circuit ;
IN: http.tests
-{ "text/plain" "UTF-8" } [ "text/plain" parse-content-type ] unit-test
+[ "text/plain" "UTF-8" ] [ "text/plain" parse-content-type ] unit-test
-{ "text/html" "ASCII" } [ "text/html; charset=ASCII" parse-content-type ] unit-test
+[ "text/html" "ASCII" ] [ "text/html; charset=ASCII" parse-content-type ] unit-test
-{ "text/html" "utf-8" } [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test
+[ "text/html" "utf-8" ] [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test
-{ "application/octet-stream" f } [ "application/octet-stream" parse-content-type ] unit-test
+[ "application/octet-stream" f ] [ "application/octet-stream" parse-content-type ] unit-test
-{ "localhost" f } [ "localhost" parse-host ] unit-test
-{ "localhost" 8888 } [ "localhost:8888" parse-host ] unit-test
-{ "::1" 8888 } [ "::1:8888" parse-host ] unit-test
-{ "127.0.0.1" 8888 } [ "127.0.0.1:8888" parse-host ] unit-test
+[ "localhost" f ] [ "localhost" parse-host ] unit-test
+[ "localhost" 8888 ] [ "localhost:8888" parse-host ] unit-test
+[ "::1" 8888 ] [ "::1:8888" parse-host ] unit-test
+[ "127.0.0.1" 8888 ] [ "127.0.0.1:8888" parse-host ] unit-test
-{ "localhost" } [ T{ url { protocol "http" } { host "localhost" } } unparse-host ] unit-test
-{ "localhost" } [ T{ url { protocol "http" } { host "localhost" } { port 80 } } unparse-host ] unit-test
-{ "localhost" } [ T{ url { protocol "https" } { host "localhost" } { port 443 } } unparse-host ] unit-test
-{ "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
+[ "localhost" ] [ T{ url { protocol "http" } { host "localhost" } } unparse-host ] unit-test
+[ "localhost" ] [ T{ url { protocol "http" } { host "localhost" } { port 80 } } unparse-host ] unit-test
+[ "localhost" ] [ T{ url { protocol "https" } { host "localhost" } { port 443 } } unparse-host ] unit-test
+[ "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
STRING: read-request-test-1
POST /bar HTTP/1.1
blah
;
-{
+[
T{ request
{ url T{ url { path "/bar" } } }
{ method "POST" }
{ cookies V{ } }
{ redirects 10 }
}
-} [
+] [
read-request-test-1 lf>crlf [
read-request
] with-string-reader
blah
;
-read-request-test-1' } [
+read-request-test-1' 1array [
read-request-test-1 lf>crlf
[ read-request ] with-string-reader
[ write-request ] with-string-writer
;
-{
+[
T{ request
{ url T{ url { host "www.sex.com" } { path "/bar" } } }
{ method "HEAD" }
{ cookies V{ } }
{ redirects 10 }
}
-} [
+] [
read-request-test-2 lf>crlf [
read-request
] with-string-reader
;
-{
+[
T{ request
{ url T{ url { host "www.sex.com" } { port 101 } { path "/bar" } } }
{ method "HEAD" }
{ cookies V{ } }
{ redirects 10 }
}
-} [
+] [
read-request-test-2' lf>crlf [
read-request
] with-string-reader
Host: "www.amazon.com"
;
-{ "www.amazon.com" }
+[ "www.amazon.com" ]
[
read-request-test-4 lf>crlf [ read-request ] with-string-reader
"host" header
blah
;
-{
+[
T{ response
{ version "1.1" }
{ code 404 }
{ content-charset "UTF-8" }
{ content-encoding utf8 }
}
-} [
+] [
read-response-test-1 lf>crlf
[ read-response ] with-string-reader
] unit-test
;
-read-response-test-1' } [
+read-response-test-1' 1array [
URL" http://localhost/" url set
read-response-test-1 lf>crlf
[ read-response ] with-string-reader
string-lines "\n" join
] unit-test
-{ t } [
+[ t ] [
"rmid=732423sdfs73242; path=/; domain=.example.net; expires=Fri, 31-Dec-2010 23:59:59 GMT"
dup parse-set-cookie first unparse-set-cookie =
] unit-test
-{ t } [
+[ t ] [
"a="
dup parse-set-cookie first unparse-set-cookie =
] unit-test
;
-{ 2 } [
+[ 2 ] [
read-response-test-2 lf>crlf
[ read-response ] with-string-reader
cookies>> length
;
-{ 1 } [
+[ 1 ] [
read-response-test-3 lf>crlf
[ read-response ] with-string-reader
cookies>> length
"http://localhost/quit" add-addr http-get nip
"Goodbye" assert= ;
-{ } [
+[ ] [
[ test-db-file delete-file ] ignore-errors
test-db [
] test-with-db-persistence
! Test cloning
-{ f } [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test
-{ f } [ <404> dup clone "b" "a" <cookie> put-cookie drop "a" get-cookie ] unit-test
+[ f ] [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test
+[ f ] [ <404> dup clone "b" "a" <cookie> put-cookie drop "a" get-cookie ] unit-test
! Test basic auth
-{ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" } [
+[ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" ] [
<request> "Aladdin" "open sesame" set-basic-auth "Authorization" header
] unit-test