-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
{ 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 }
}
} [
{ 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 }
}
} [
{ "DELETE" } [ "http://arc.com" <delete-request> method>> ] unit-test
{ "TRACE" } [ "http://concatenative.org" <trace-request> method>> ] unit-test
{ "OPTIONS" } [ "http://factorcode.org" <options-request> method>> ] unit-test
-{ t } [
- "https://alice.sni.velox.ch" http-get nip
- [ "Great!" swap subseq? ]
- [ "TLS SNI Test Site: alice.sni.velox.ch" swap subseq? ] bi and
-] unit-test
+
+! Do not re-enable this for the test suite.
+! We should replace this with a similar test that does not
+! hit the velox.ch website.
+! { t } [
+ ! "https://alice.sni.velox.ch" http-get nip
+ ! [ "Great!" subseq-of? ]
+ ! [ "TLS SNI Test Site: alice.sni.velox.ch" subseq-of? ] bi and
+! ] unit-test
{ t } [
{
"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
] with-variables
] unit-test
+{ URL" //localhost:3128" } [
+ { { "http.proxy" "//localhost:3128" } } [
+ "google.com" "GET" <client-request> ?default-proxy proxy-url>>
+ ] with-variables
+] unit-test
+
+{ URL" //localhost:3128" } [
+ "google.com" "GET" <client-request>
+ URL" //localhost:3128" >>proxy-url ?default-proxy proxy-url>>
+] unit-test
+
+{ URL" //localhost:3128" } [
+ "google.com" "GET" <client-request>
+ "//localhost:3128" >>proxy-url ?default-proxy proxy-url>>
+] unit-test
+
{ URL" http://proxysec.private:3128" } [
classic-proxy-settings [
"https://google.com" "GET" <client-request> ?default-proxy proxy-url>>
"allprivate.google.com" "GET" <client-request> ?default-proxy proxy-url>>
] with-variables
] unit-test
+
+[
+ <url> 3128 >>port "http.proxy" [
+ "http://www.google.com" "GET" <client-request> ?default-proxy
+ ] with-variable
+] [ invalid-proxy? ] must-fail-with
+
+! This url is misparsed bu request-url can fix it
+{ T{ url
+ { protocol "http" }
+ { host "www.google.com" }
+ { path "/" }
+ { port 80 }
+} } [ "www.google.com" request-url ] unit-test
+
+! This one is not fixable, leave it as it is
+{ T{ url } } [ "" request-url ] unit-test