]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/http/client/client-tests.factor
core: subseq-index? -> subseq-of?
[factor.git] / basis / http / client / client-tests.factor
index 651770acc8ec437e7b8684670a6de63951e1af32..49b897180e86c942f75e17db7119fa77e1fb8a7c 100644 (file)
@@ -1,10 +1,8 @@
-USING: accessors io.sockets.secure http.client http.client.private http
-io.streams.string kernel namespaces sequences tools.test urls ;
+USING: accessors http http.client http.client.private
+io.streams.string kernel namespaces sequences splitting
+tools.test urls ;
 IN: http.client.tests
 
-{ "localhost" f } [ "localhost" parse-host ] unit-test
-{ "localhost" 8888 } [ "localhost:8888" parse-host ] unit-test
-
 { "foo.txt" } [ "http://www.paulgraham.com/foo.txt" download-name ] unit-test
 { "foo.txt" } [ "http://www.arc.com/foo.txt?xxx" download-name ] unit-test
 { "foo.txt" } [ "http://www.arc.com/foo.txt/" download-name ] unit-test
@@ -17,7 +15,7 @@ IN: http.client.tests
         { method "GET" }
         { version "1.1" }
         { cookies V{ } }
-        { header H{ { "connection" "close" } { "user-agent" "Factor http.client" } } }
+        { header H{ { "Connection" "close" } { "User-Agent" "Factor http.client" } } }
         { redirects 10 }
     }
 } [
@@ -32,7 +30,7 @@ IN: http.client.tests
         { method "GET" }
         { version "1.1" }
         { cookies V{ } }
-        { header H{ { "connection" "close" } { "user-agent" "Factor http.client" } } }
+        { header H{ { "Connection" "close" } { "User-Agent" "Factor http.client" } } }
         { redirects 10 }
     }
 } [
@@ -50,8 +48,8 @@ IN: http.client.tests
 ! hit the velox.ch website.
 ! { t } [
     ! "https://alice.sni.velox.ch" http-get nip
-    ! [ "Great!" swap subseq? ]
-    ! [ "TLS SNI Test Site: alice.sni.velox.ch" swap subseq? ] bi and
+    ! [ "Great!" subseq-of? ]
+    ! [ "TLS SNI Test Site: alice.sni.velox.ch" subseq-of? ] bi and
 ! ] unit-test
 
 { t } [
@@ -61,7 +59,7 @@ IN: http.client.tests
         "content-type: text/html; charset=UTF-8"
         "date: Wed, 12 Oct 2011 18:57:49 GMT"
         "server: Factor http.server"
-    } [ "\n" join ] [ "\r\n" join ] bi
+    } [ join-lines ] [ "\r\n" join ] bi
     [ [ read-response ] with-string-reader ] same?
 ] unit-test
 
@@ -195,20 +193,20 @@ CONSTANT: classic-proxy-settings H{
     ] with-variables
 ] unit-test
 
-{ URL" http://localhost:3128" } [
-    { { "http.proxy" "localhost:3128" } } [
+{ URL" //localhost:3128" } [
+    { { "http.proxy" "//localhost:3128" } } [
        "google.com" "GET" <client-request> ?default-proxy proxy-url>>
     ] with-variables
 ] unit-test
 
-{ URL" http://localhost:3128" } [
+{ URL" //localhost:3128" } [
     "google.com" "GET" <client-request>
-    URL" localhost:3128" >>proxy-url ?default-proxy proxy-url>>
+    URL" //localhost:3128" >>proxy-url ?default-proxy proxy-url>>
 ] unit-test
 
-{ URL" http://localhost:3128" } [
+{ URL" //localhost:3128" } [
     "google.com" "GET" <client-request>
-    "localhost:3128" >>proxy-url ?default-proxy proxy-url>>
+    "//localhost:3128" >>proxy-url ?default-proxy proxy-url>>
 ] unit-test
 
 { URL" http://proxysec.private:3128" } [