From 9bf7f56283ce7adfe731367efbe94a0577b7d79c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 25 Feb 2010 18:05:10 -0600 Subject: [PATCH] Add a new word http-data that is just http-get nip --- .../bootstrap/image/download/download.factor | 2 +- basis/http/client/client.factor | 3 +++ basis/http/http-tests.factor | 22 +++++++++---------- basis/syndication/syndication.factor | 2 +- extra/images/http/http.factor | 2 +- extra/webapps/fjsc/fjsc.factor | 2 +- extra/yahoo/yahoo.factor | 2 +- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index e2de621984..9ab7689eca 100644 --- a/basis/bootstrap/image/download/download.factor +++ b/basis/bootstrap/image/download/download.factor @@ -7,7 +7,7 @@ IN: bootstrap.image.download CONSTANT: url URL" http://factorcode.org/images/latest/" : download-checksums ( -- alist ) - url "checksums.txt" >url derive-url http-get nip + url "checksums.txt" >url derive-url http-data string-lines [ " " split1 ] { } map>assoc ; : need-new-image? ( image -- ? ) diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 482a23aeaa..9e540f111f 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -157,6 +157,9 @@ ERROR: download-failed response ; : http-get ( url -- response data ) http-request ; +: http-data ( url -- data ) + http-get nip ; + : with-http-get ( url quot -- response ) [ ] dip with-http-request ; inline diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 35d01c1014..62936af7ff 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -226,14 +226,14 @@ test-db [ [ t ] [ "vocab:http/test/foo.html" ascii file-contents - "http://localhost/nested/foo.html" add-port http-get nip = + "http://localhost/nested/foo.html" add-port http-data = ] unit-test -[ "http://localhost/redirect-loop" add-port http-get nip ] +[ "http://localhost/redirect-loop" add-port http-data ] [ too-many-redirects? ] must-fail-with [ "Goodbye" ] [ - "http://localhost/quit" add-port http-get nip + "http://localhost/quit" add-port http-data ] unit-test ! HTTP client redirect bug @@ -247,7 +247,7 @@ test-db [ ] unit-test [ "Goodbye" ] [ - "http://localhost/redirect" add-port http-get nip + "http://localhost/redirect" add-port http-data ] unit-test @@ -274,12 +274,12 @@ test-db [ : 404? ( response -- ? ) [ download-failed? ] [ response>> code>> 404 = ] bi and ; ! This should give a 404 not an infinite redirect loop -[ "http://localhost/d/blah" add-port http-get nip ] [ 404? ] must-fail-with +[ "http://localhost/d/blah" add-port http-data ] [ 404? ] must-fail-with ! This should give a 404 not an infinite redirect loop -[ "http://localhost/blah/" add-port http-get nip ] [ 404? ] must-fail-with +[ "http://localhost/blah/" add-port http-data ] [ 404? ] must-fail-with -[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test [ ] [ @@ -293,9 +293,9 @@ test-db [ test-httpd ] unit-test -[ "Hi" ] [ "http://localhost/" add-port http-get nip ] unit-test +[ "Hi" ] [ "http://localhost/" add-port http-data ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test USING: html.components html.forms xml xml.traversal validators @@ -353,7 +353,7 @@ SYMBOL: a [ 4 ] [ a get-global ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test ! Test cloning [ f ] [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test @@ -371,7 +371,7 @@ SYMBOL: a ] unit-test [ t ] [ - "http://localhost/" add-port http-get nip + "http://localhost/" add-port http-data "vocab:http/test/foo.html" ascii file-contents = ] unit-test diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index fe31a49265..edfbebeeab 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -115,7 +115,7 @@ M: byte-array parse-feed [ bytes>xml xml>feed ] with-html-entities ; : download-feed ( url -- feed ) #! Retrieve an news syndication file, return as a feed tuple. - http-get nip parse-feed ; + http-data parse-feed ; ! Atom generation diff --git a/extra/images/http/http.factor b/extra/images/http/http.factor index 620ab6f73b..d3cff18afb 100644 --- a/extra/images/http/http.factor +++ b/extra/images/http/http.factor @@ -5,7 +5,7 @@ images.viewer ; IN: images.http : load-http-image ( path -- image ) - [ http-get nip ] [ image-class ] bi load-image* ; + [ http-data ] [ image-class ] bi load-image* ; : http-image. ( path -- ) load-http-image image. ; diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor index 01d6935bee..4dec258083 100644 --- a/extra/webapps/fjsc/fjsc.factor +++ b/extra/webapps/fjsc/fjsc.factor @@ -35,7 +35,7 @@ TUPLE: fjsc < dispatcher ; : do-compile-url ( url -- response ) [ - absolute-url http-get nip 'expression' parse fjsc-compile write "();" write + absolute-url http-data 'expression' parse fjsc-compile write "();" write ] with-string-writer "application/javascript" ; diff --git a/extra/yahoo/yahoo.factor b/extra/yahoo/yahoo.factor index 5e0c08b430..2a8469c328 100644 --- a/extra/yahoo/yahoo.factor +++ b/extra/yahoo/yahoo.factor @@ -57,4 +57,4 @@ CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugB swap >>query ; : search-yahoo ( search -- seq ) - query http-get nip string>xml parse-yahoo ; + query http-data string>xml parse-yahoo ;