]> gitweb.factorcode.org Git - factor.git/blob - basis/http/client/client-tests.factor
c391b417a932eaab87c5f3d6bf94009928eb4cda
[factor.git] / basis / http / client / client-tests.factor
1 USING: http.client http.client.private http tools.test
2 namespaces urls ;
3
4 [ "localhost" f ] [ "localhost" parse-host ] unit-test
5 [ "localhost" 8888 ] [ "localhost:8888" parse-host ] unit-test
6
7 [ "foo.txt" ] [ "http://www.paulgraham.com/foo.txt" download-name ] unit-test
8 [ "foo.txt" ] [ "http://www.arc.com/foo.txt?xxx" download-name ] unit-test
9 [ "foo.txt" ] [ "http://www.arc.com/foo.txt/" download-name ] unit-test
10 [ "www.arc.com" ] [ "http://www.arc.com////" download-name ] unit-test
11
12 [
13     T{ request
14         { url T{ url { protocol "http" } { host "www.apple.com" } { port 80 } { path "/index.html" } } }
15         { method "GET" }
16         { version "1.1" }
17         { cookies V{ } }
18         { header H{ { "connection" "close" } { "user-agent" "Factor http.client" } } }
19         { redirects 10 }
20     }
21 ] [
22     "http://www.apple.com/index.html"
23     <get-request>
24 ] unit-test
25
26 [
27     T{ request
28         { url T{ url { protocol "https" } { host "www.amazon.com" } { port 443 } { path "/index.html" } } }
29         { method "GET" }
30         { version "1.1" }
31         { cookies V{ } }
32         { header H{ { "connection" "close" } { "user-agent" "Factor http.client" } } }
33         { redirects 10 }
34     }
35 ] [
36     "https://www.amazon.com/index.html"
37     <get-request>
38 ] unit-test