1 USING: accessors http http.client http.client.private
2 io.streams.string kernel namespaces sequences splitting
8 { url T{ url { protocol "http" } { host "www.apple.com" } { port 80 } { path "/index.html" } } }
13 { header H{ { "Connection" "close" } { "User-Agent" "Factor http.client" } } }
17 "http://www.apple.com/index.html"
23 { url T{ url { protocol "https" } { host "www.amazon.com" } { port 443 } { path "/index.html" } } }
24 { proxy-url T{ url } }
28 { header H{ { "Connection" "close" } { "User-Agent" "Factor http.client" } } }
32 "https://www.amazon.com/index.html"
36 { "HEAD" } [ "http://google.com" <head-request> method>> ] unit-test
37 { "DELETE" } [ "http://arc.com" <delete-request> method>> ] unit-test
38 { "TRACE" } [ "http://concatenative.org" <trace-request> method>> ] unit-test
39 { "OPTIONS" } [ "http://factorcode.org" <options-request> method>> ] unit-test
41 ! Do not re-enable this for the test suite.
42 ! We should replace this with a similar test that does not
43 ! hit the velox.ch website.
45 ! "https://alice.sni.velox.ch" http-get nip
46 ! [ "Great!" subseq-of? ]
47 ! [ "TLS SNI Test Site: alice.sni.velox.ch" subseq-of? ] bi and
52 "HTTP/1.1 200 Document follows"
54 "content-type: text/html; charset=UTF-8"
55 "date: Wed, 12 Oct 2011 18:57:49 GMT"
56 "server: Factor http.server"
57 } [ join-lines ] [ "\r\n" join ] bi
58 [ [ read-response ] with-string-reader ] same?
61 { "www.google.com:8080" } [
62 URL" http://foo:bar@www.google.com:8080/foo?bar=baz#quux" authority-uri
65 { "/index.html?bar=baz" } [
66 "http://user:pass@www.apple.com/index.html?bar=baz#foo"
72 { "/index.html?bar=baz" } [
73 "https://user:pass@www.apple.com/index.html?bar=baz#foo"
79 { "http://www.apple.com/index.html?bar=baz" } [
80 "http://user:pass@www.apple.com/index.html?bar=baz#foo"
82 "http://localhost:3128" >>proxy-url
86 { "www.apple.com:80" } [
87 "http://user:pass@www.apple.com/index.html?bar=baz#foo"
88 "CONNECT" <client-request>
93 { "www.apple.com:443" } [
94 "https://www.apple.com/index.html"
95 "CONNECT" <client-request>
102 "www.google.fr" <get-request> no-proxy?
108 "www.google.fr" <get-request> no-proxy?
113 "foo,,bar" "no_proxy" [
114 "www.google.fr" <get-request> no-proxy?
119 "foo,www.google.fr,bar" "no_proxy" [
120 "www.google.fr" <get-request> no-proxy?
124 ! TODO support 192.168.0.16/4 ?
125 CONSTANT: classic-proxy-settings H{
126 { "http.proxy" "http://proxy.private:3128" }
127 { "https.proxy" "http://proxysec.private:3128" }
128 { "no_proxy" "localhost,127.0.0.1,.allprivate,.a.subprivate,b.subprivate" }
132 classic-proxy-settings [
133 "localhost" "GET" <client-request> ?default-proxy proxy-url>>
138 classic-proxy-settings [
139 "127.0.0.1" "GET" <client-request> ?default-proxy proxy-url>>
143 { URL" http://proxy.private:3128" } [
144 classic-proxy-settings [
145 "27.0.0.1" "GET" <client-request> ?default-proxy proxy-url>>
150 classic-proxy-settings [
151 "foo.allprivate" "GET" <client-request> ?default-proxy proxy-url>>
156 classic-proxy-settings [
157 "bar.a.subprivate" "GET" <client-request> ?default-proxy proxy-url>>
161 { URL" http://proxy.private:3128" } [
162 classic-proxy-settings [
163 "a.subprivate" "GET" <client-request> ?default-proxy proxy-url>>
168 classic-proxy-settings [
169 "bar.b.subprivate" "GET" <client-request> ?default-proxy proxy-url>>
174 classic-proxy-settings [
175 "b.subprivate" "GET" <client-request> ?default-proxy proxy-url>>
179 { URL" http://proxy.private:3128" } [
180 classic-proxy-settings [
181 "bara.subprivate" "GET" <client-request> ?default-proxy proxy-url>>
185 { URL" http://proxy.private:3128" } [
186 classic-proxy-settings [
187 "google.com" "GET" <client-request> ?default-proxy proxy-url>>
191 { URL" //localhost:3128" } [
192 { { "http.proxy" "//localhost:3128" } } [
193 "google.com" "GET" <client-request> ?default-proxy proxy-url>>
197 { URL" //localhost:3128" } [
198 "google.com" "GET" <client-request>
199 URL" //localhost:3128" >>proxy-url ?default-proxy proxy-url>>
202 { URL" //localhost:3128" } [
203 "google.com" "GET" <client-request>
204 "//localhost:3128" >>proxy-url ?default-proxy proxy-url>>
207 { URL" http://proxysec.private:3128" } [
208 classic-proxy-settings [
209 "https://google.com" "GET" <client-request> ?default-proxy proxy-url>>
213 { URL" http://proxy.private:3128" } [
214 classic-proxy-settings [
215 "allprivate.google.com" "GET" <client-request> ?default-proxy proxy-url>>
220 <url> 3128 >>port "http.proxy" [
221 "http://www.google.com" "GET" <client-request> ?default-proxy
223 ] [ invalid-proxy? ] must-fail-with
225 ! This url is misparsed bu request-url can fix it
228 { host "www.google.com" }
231 } } [ "www.google.com" request-url ] unit-test
233 ! This one is not fixable, leave it as it is
234 { T{ url } } [ "" request-url ] unit-test