From 712be93989b4196005eb849eca4433549dc202cb Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 12 Mar 2014 19:29:35 -0700 Subject: [PATCH] http.client: remove http-get* and its friends, change http-request* and with-http-request* to not check response codes. --- .../bootstrap/image/download/download.factor | 2 +- .../semaphores/semaphores-docs.factor | 2 +- basis/furnace/recaptcha/recaptcha.factor | 2 +- basis/http/client/client-docs.factor | 79 +++++-------------- basis/http/client/client.factor | 62 +++++---------- basis/syndication/syndication.factor | 2 +- extra/bit/ly/ly.factor | 2 +- extra/google/charts/charts.factor | 2 +- extra/google/search/search.factor | 2 +- extra/google/translate/translate.factor | 2 +- extra/hacker-news/hacker-news.factor | 2 +- extra/mason/updates/updates.factor | 2 +- extra/reddit/reddit.factor | 4 +- extra/robots/robots.factor | 2 +- .../web-scraping/web-scraping.factor | 2 +- extra/twitter/prettyprint/prettyprint.factor | 2 +- extra/webapps/fjsc/fjsc.factor | 5 +- extra/wikipedia/wikipedia.factor | 4 +- extra/wolfram-alpha/wolfram-alpha.factor | 2 +- extra/xkcd/xkcd.factor | 7 +- extra/yahoo/yahoo.factor | 2 +- extra/youtube/youtube.factor | 2 +- 22 files changed, 65 insertions(+), 128 deletions(-) diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index 9d613a5148..15a0e679c5 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://downloads.factorcode.org/images/latest/" : download-checksums ( -- alist ) - url "checksums.txt" >url derive-url http-get* + url "checksums.txt" >url derive-url http-get nip string-lines [ " " split1 ] { } map>assoc ; : file-checksum ( image -- checksum ) diff --git a/basis/concurrency/semaphores/semaphores-docs.factor b/basis/concurrency/semaphores/semaphores-docs.factor index 4fdecee273..06c951f586 100644 --- a/basis/concurrency/semaphores/semaphores-docs.factor +++ b/basis/concurrency/semaphores/semaphores-docs.factor @@ -53,7 +53,7 @@ fry http.client kernel urls ; URL" http://www.oracle.com" } 2 '[ - _ [ http-get* ] with-semaphore + _ [ http-get nip ] with-semaphore ] parallel-map""" } ; diff --git a/basis/furnace/recaptcha/recaptcha.factor b/basis/furnace/recaptcha/recaptcha.factor index 2e9af622d0..3ae20f14bb 100644 --- a/basis/furnace/recaptcha/recaptcha.factor +++ b/basis/furnace/recaptcha/recaptcha.factor @@ -59,7 +59,7 @@ M: recaptcha call-responder* { "privatekey" private-key } { "remoteip" remote-ip } } URL" http://api-verify.recaptcha.net/verify" - http-post* parse-recaptcha-response ; + http-post nip parse-recaptcha-response ; : validate-recaptcha-params ( -- ) { diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor index bfc63fa3b0..5a622a21ab 100644 --- a/basis/http/client/client-docs.factor +++ b/basis/http/client/client-docs.factor @@ -55,98 +55,60 @@ HELP: http-get { $description "Downloads the contents of a URL." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-get* -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-get } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-post { $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP POST request." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-post* -{ $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-post } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-put { $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP PUT request." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-put* -{ $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-put } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-head { $values { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Same as " { $link http-get } " except that the server is not supposed to return a message-body in the response, as per RFC2616. However in practise, most web servers respond to GET and HEAD method calls with identical responses." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-head* -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-head } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-delete { $values { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Requests that the origin server delete the resource identified by the URL." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-delete* -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-delete } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-options { $values { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP OPTIONS request." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-options* -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-options } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-trace { $values { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP TRACE request." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-trace* -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "A variant of " { $link http-trace } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - -HELP: with-http-get -{ $values { "url" "a " { $link url } " or " { $link string } } { "quot" { $quotation "( chunk -- )" } } { "response" response } } -{ $description "Downloads the contents of a URL. Chunks of data are passed to the quotation as they are read." } -{ $errors "Throws an error if the HTTP request fails." } ; - -HELP: with-http-get* -{ $values { "url" "a " { $link url } " or " { $link string } } { "quot" { $quotation "( chunk -- )" } } } -{ $description "A variant of " { $link with-http-get } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; - HELP: http-request { $values { "request" request } { "response" response } { "data" sequence } } -{ $description "Sends an HTTP request to an HTTP server, and reads the response." } +{ $description "A variant of " { $link http-request* } " that checks that the response was successful." } { $errors "Throws an error if the HTTP request fails." } ; HELP: http-request* -{ $values { "request" request } { "data" sequence } } -{ $description "A variant of " { $link http-request } " that checks that the response was successful." } -{ $errors "Throws an error if the HTTP request fails or is not successful." } ; +{ $values { "request" request } { "response" response } { "data" sequence } } +{ $description "Sends an HTTP request to an HTTP server, and reads the response." } ; HELP: with-http-request { $values { "request" request } { "quot" { $quotation "( chunk -- )" } } { "response" response } } +{ $description "A variant of " { $link with-http-request* } " that checks that the response was successful." } ; + +HELP: with-http-request* +{ $values { "request" request } { "quot" { $quotation "( chunk -- )" } } { "response" response } } { $description "Sends an HTTP request to an HTTP server, and reads the response incrementally. Chunks of data are passed to the quotation as they are read. Does not throw an error if the HTTP request fails; to do so, call " { $link check-response } " on the " { $snippet "response" } "." } ; +{ http-request http-request* with-http-request with-http-request* } related-words + ARTICLE: "http.client.get" "GET requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-get http-get* } +{ $subsections + http-get +} "Utilities to retrieve a " { $link url } " and save the contents to a file:" { $subsections download @@ -158,11 +120,10 @@ ARTICLE: "http.client.get" "GET requests with the HTTP client" http-request http-request* } -"The " { $link http-get } " and " { $link http-request } " words output sequences. This is undesirable if the response data may be large. Another pair of words take a quotation instead, and pass the quotation chunks of data incrementally:" +"The " { $link http-request } " and " { $link http-request* } " words output sequences. This is undesirable if the response data may be large. Another pair of words take a quotation instead, and pass the quotation chunks of data incrementally:" { $subsections - with-http-get - with-http-get* with-http-request + with-http-request* } ; ARTICLE: "http.client.post-data" "HTTP client post data" @@ -185,21 +146,21 @@ ARTICLE: "http.client.post-data" "HTTP client post data" ARTICLE: "http.client.post" "POST requests with the HTTP client" "Basic usage involves passing post data and a " { $link url } ", and getting a " { $link response } " and data back:" -{ $subsections http-post http-post* } +{ $subsections http-post } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections } "Both words take a post data parameter; see " { $link "http.client.post-data" } "." ; ARTICLE: "http.client.put" "PUT requests with the HTTP client" "Basic usage involves passing post data and a " { $link url } ", and getting a " { $link response } " and data back:" -{ $subsections http-put http-put* } +{ $subsections http-put } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections } "Both words take a post data parameter; see " { $link "http.client.post-data" } "." ; ARTICLE: "http.client.head" "HEAD requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-head http-head* } +{ $subsections http-head } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections @@ -207,7 +168,7 @@ ARTICLE: "http.client.head" "HEAD requests with the HTTP client" ARTICLE: "http.client.delete" "DELETE requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-delete http-delete* } +{ $subsections http-delete } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections @@ -215,7 +176,7 @@ ARTICLE: "http.client.delete" "DELETE requests with the HTTP client" ARTICLE: "http.client.options" "OPTIONS requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-options http-options* } +{ $subsections http-options } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections @@ -224,7 +185,7 @@ ARTICLE: "http.client.options" "OPTIONS requests with the HTTP client" ARTICLE: "http.client.trace" "TRACE requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-trace http-trace* } +{ $subsections http-trace } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 5d5e121f0a..c0adf0e94b 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -1,14 +1,12 @@ ! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs combinators.short-circuit kernel math math.parser -namespaces make sequences strings splitting calendar -continuations accessors vectors math.order hashtables -byte-arrays destructors io io.sockets io.streams.string io.files -io.timeouts io.pathnames io.encodings io.encodings.string -io.encodings.ascii io.encodings.utf8 io.encodings.binary -io.encodings.iana io.crlf io.streams.duplex fry ascii urls -urls.encoding present locals http http.parsers -http.client.post-data mime.types ; +USING: accessors ascii assocs calendar combinators.short-circuit +destructors fry hashtables http http.client.post-data +http.parsers io io.crlf io.encodings io.encodings.ascii +io.encodings.binary io.encodings.iana io.encodings.string +io.files io.pathnames io.sockets io.timeouts kernel locals math +math.order math.parser mime.types namespaces present sequences +splitting urls vocabs.loader ; IN: http.client ERROR: too-many-redirects ; @@ -163,15 +161,18 @@ ERROR: download-failed response ; : check-response-with-body ( response body -- response body ) [ >>body check-response ] keep ; -: with-http-request ( request quot: ( chunk -- ) -- response ) +: with-http-request* ( request quot: ( chunk -- ) -- response ) [ (with-http-request) ] with-destructors ; inline -: http-request ( request -- response data ) - [ [ % ] with-http-request ] B{ } make - over content-encoding>> decode check-response-with-body ; +: with-http-request ( request quot: ( chunk -- ) -- response ) + with-http-request* check-response ; inline -: http-request* ( request -- data ) - http-request swap check-response drop ; +: http-request* ( request -- response data ) + BV{ } clone [ '[ _ push-all ] with-http-request* ] keep + B{ } like over content-encoding>> decode [ >>body ] keep ; + +: http-request ( request -- response data ) + http-request* [ check-response ] dip ; : ( url -- request ) "GET" ; @@ -179,20 +180,13 @@ ERROR: download-failed response ; : http-get ( url -- response data ) http-request ; -: http-get* ( url -- data ) - http-get swap check-response drop ; - -: with-http-get ( url quot: ( chunk -- ) -- response ) - [ ] dip with-http-request ; inline - -: with-http-get* ( url quot: ( chunk -- ) -- ) - with-http-get check-response drop ; inline - : download-name ( url -- name ) present file-name "?" split1 drop "/" ?tail drop ; : download-to ( url file -- ) - binary [ [ write ] with-http-get* ] with-file-writer ; + binary [ + [ write ] with-http-request drop + ] with-file-writer ; : download ( url -- ) dup download-name download-to ; @@ -204,9 +198,6 @@ ERROR: download-failed response ; : http-post ( post-data url -- response data ) http-request ; -: http-post* ( post-data url -- data ) - http-post swap check-response drop ; - : ( post-data url -- request ) "PUT" swap >>post-data ; @@ -214,45 +205,30 @@ ERROR: download-failed response ; : http-put ( post-data url -- response data ) http-request ; -: http-put* ( post-data url -- data ) - http-put swap check-response drop ; - : ( url -- request ) "DELETE" ; : http-delete ( url -- response data ) http-request ; -: http-delete* ( url -- data ) - http-delete swap check-response drop ; - : ( url -- request ) "HEAD" ; : http-head ( url -- response data ) http-request ; -: http-head* ( url -- data ) - http-head swap check-response drop ; - : ( url -- request ) "OPTIONS" ; : http-options ( url -- response data ) http-request ; -: http-options* ( url -- data ) - http-options swap check-response drop ; - : ( url -- request ) "TRACE" ; : http-trace ( url -- response data ) http-request ; -: http-trace* ( url -- data ) - http-trace swap check-response drop ; - USE: vocabs.loader { "http.client" "debugger" } "http.client.debugger" require-when diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index 8e9150f693..407e09aab1 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -108,7 +108,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* parse-feed ; + http-get nip parse-feed ; ! Atom generation diff --git a/extra/bit/ly/ly.factor b/extra/bit/ly/ly.factor index c89c3791bd..f69eff34b0 100644 --- a/extra/bit/ly/ly.factor +++ b/extra/bit/ly/ly.factor @@ -23,7 +23,7 @@ ERROR: bad-response json status ; ] unless ; : json-data ( url -- json ) - http-get* json> check-status "data" of ; + http-get nip json> check-status "data" of ; : get-short-url ( short-url path -- data ) swap "shortUrl" set-query-param json-data ; diff --git a/extra/google/charts/charts.factor b/extra/google/charts/charts.factor index 39a615043e..d97a97bceb 100644 --- a/extra/google/charts/charts.factor +++ b/extra/google/charts/charts.factor @@ -100,6 +100,6 @@ PRIVATE> : chart. ( chart -- ) chart>url present dup length 2000 < [ http-image. ] [ - "?" split1 swap http-post* + "?" split1 swap http-post nip "png" (image-class) load-image* image. ] if ; diff --git a/extra/google/search/search.factor b/extra/google/search/search.factor index d3d8002f7a..4518b11480 100644 --- a/extra/google/search/search.factor +++ b/extra/google/search/search.factor @@ -22,7 +22,7 @@ title content unescapedUrl url titleNoFormatting fileFormat ; PRIVATE> : google-search ( query -- results ) - search-url http-get* json> + search-url http-get nip json> { "responseData" "results" } deep-at [ \ search-result from-slots ] map ; diff --git a/extra/google/translate/translate.factor b/extra/google/translate/translate.factor index 40f810a640..a7a49d52ca 100644 --- a/extra/google/translate/translate.factor +++ b/extra/google/translate/translate.factor @@ -16,7 +16,7 @@ CONSTANT: maximum-translation-size 5120 ] { } make ; : assoc>query-response ( assoc -- response ) - google-translate-url http-post* ; + google-translate-url http-post nip ; ERROR: response-error response error ; diff --git a/extra/hacker-news/hacker-news.factor b/extra/hacker-news/hacker-news.factor index 3e2e91f186..e7faaccf38 100644 --- a/extra/hacker-news/hacker-news.factor +++ b/extra/hacker-news/hacker-news.factor @@ -25,7 +25,7 @@ TUPLE: post title postedBy points id url commentCount postedAgo ; ] map ; : hacker-news-items ( -- seq ) - "http://api.ihackernews.com/page" http-get* + "http://api.ihackernews.com/page" http-get nip json> "items" of items> ; : write-title ( title url -- ) diff --git a/extra/mason/updates/updates.factor b/extra/mason/updates/updates.factor index ca24d98515..016c1a6d79 100644 --- a/extra/mason/updates/updates.factor +++ b/extra/mason/updates/updates.factor @@ -21,7 +21,7 @@ SYMBOLS: latest-sources last-built-sources ; [ maybe-download-image drop ] [ file-checksum ] bi ; : latest-counter ( -- counter ) - counter-url get-global http-get* string>number ; + counter-url get-global http-get nip string>number ; : update-sources ( -- ) #! Must be run from builds-dir diff --git a/extra/reddit/reddit.factor b/extra/reddit/reddit.factor index 40cc4ad95a..c6618af1b3 100644 --- a/extra/reddit/reddit.factor +++ b/extra/reddit/reddit.factor @@ -44,7 +44,7 @@ public_description subscribers title url ; TUPLE: page url data before after ; : json-page ( url -- page ) - >url dup http-get* json> "data" of { + >url dup http-get nip json> "data" of { [ "children" of [ parse-data ] map ] [ "before" of [ f ] when-json-null ] [ "after" of [ f ] when-json-null ] @@ -55,7 +55,7 @@ TUPLE: page url data before after ; : get-user-info ( username -- user ) "http://api.reddit.com/user/%s/about" sprintf - http-get* json> parse-data ; + http-get nip json> parse-data ; : get-url-info ( url -- page ) "http://api.reddit.com/api/info?url=%s" sprintf json-page ; diff --git a/extra/robots/robots.factor b/extra/robots/robots.factor index 580e965348..99b375da38 100644 --- a/extra/robots/robots.factor +++ b/extra/robots/robots.factor @@ -30,7 +30,7 @@ visit-time request-rate crawl-delay unknowns ; >url URL" robots.txt" derive-url ; : get-robots.txt ( url -- robots.txt ) - >robots.txt-url http-get* ; + >robots.txt-url http-get nip ; : normalize-robots.txt ( string -- sitemaps seq ) string-lines diff --git a/extra/rosetta-code/web-scraping/web-scraping.factor b/extra/rosetta-code/web-scraping/web-scraping.factor index 66f6f7c91b..402a960124 100644 --- a/extra/rosetta-code/web-scraping/web-scraping.factor +++ b/extra/rosetta-code/web-scraping/web-scraping.factor @@ -15,7 +15,7 @@ IN: rosetta-code.web-scraping ! and popular such as CPAN for Perl or Boost for C++. : web-scraping-main ( -- ) - "http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get* + "http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get nip [ "UTC" swap start [ 9 - ] [ 1 - ] bi ] keep subseq print ; MAIN: web-scraping-main diff --git a/extra/twitter/prettyprint/prettyprint.factor b/extra/twitter/prettyprint/prettyprint.factor index 26f9f89eb7..6ba528f9af 100644 --- a/extra/twitter/prettyprint/prettyprint.factor +++ b/extra/twitter/prettyprint/prettyprint.factor @@ -5,7 +5,7 @@ IN: twitter.prettyprint MEMO: load-http-image ( url -- image/f ) '[ _ - [ http-get* ] [ image-class ] bi load-image* + [ http-get nip ] [ image-class ] bi load-image* ] [ drop f ] recover ; : user-image ( user -- image/f ) diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor index 6901ea0564..52227ade16 100644 --- a/extra/webapps/fjsc/fjsc.factor +++ b/extra/webapps/fjsc/fjsc.factor @@ -34,8 +34,9 @@ TUPLE: fjsc < dispatcher ; swap append ; : do-compile-url ( url -- response ) - [ - absolute-url http-get* 'expression' parse fjsc-compile write "();" write + [ + absolute-url http-get nip 'expression' parse + fjsc-compile write "();" write ] with-string-writer "application/javascript" ; diff --git a/extra/wikipedia/wikipedia.factor b/extra/wikipedia/wikipedia.factor index 13127ff1b7..8bff89b45e 100644 --- a/extra/wikipedia/wikipedia.factor +++ b/extra/wikipedia/wikipedia.factor @@ -48,7 +48,7 @@ SYMBOL: language [ month-name ] [ day>> ] bi "%s_%s" sprintf wikipedia-url ; : (historical-events) ( timestamp -- seq ) - historical-url http-get* string>xml "ul" deep-tags-named ; + historical-url http-get nip string>xml "ul" deep-tags-named ; : items>sequence ( tag -- seq ) children-tags [ deep-children>string ] map ; @@ -74,7 +74,7 @@ PRIVATE> (historical-events) "Deaths" header. fourth items. ; : article. ( name -- ) - wikipedia-url http-get* parse-html + wikipedia-url http-get nip parse-html "content" find-by-id-between [ html-text. ] with-string-writer string-lines [ [ blank? ] trim ] map harvest [ diff --git a/extra/wolfram-alpha/wolfram-alpha.factor b/extra/wolfram-alpha/wolfram-alpha.factor index 3766cecfa4..91a4c3b36b 100644 --- a/extra/wolfram-alpha/wolfram-alpha.factor +++ b/extra/wolfram-alpha/wolfram-alpha.factor @@ -16,7 +16,7 @@ SYMBOL: wolfram-api-id : query ( query -- xml ) url-encode wolfram-api-id get-global "http://api.wolframalpha.com/v2/query?input=%s&appid=%s" - sprintf http-get* string>xml + sprintf http-get nip string>xml dup "error" tag-named [ "msg" tag-named children>string throw ] when* ; diff --git a/extra/xkcd/xkcd.factor b/extra/xkcd/xkcd.factor index f47be6483e..72f8af67f4 100644 --- a/extra/xkcd/xkcd.factor +++ b/extra/xkcd/xkcd.factor @@ -11,19 +11,18 @@ IN: xkcd string load-http-image ; : comic-image. ( url -- ) comic-image image. ; : comic-string ( url -- string ) - http-get* string>xml + http-get nip string>xml "transcript" "id" deep-tag-with-attr children>string ; : comic-text. ( url -- ) - comic-image - 80 wrap-lines [ print ] each ; + comic-image 80 wrap-lines [ print ] each ; : comic. ( url -- ) ui-running? [ comic-image. ] [ comic-text. ] if ; diff --git a/extra/yahoo/yahoo.factor b/extra/yahoo/yahoo.factor index 9a7ab25390..7800095330 100644 --- a/extra/yahoo/yahoo.factor +++ b/extra/yahoo/yahoo.factor @@ -57,4 +57,4 @@ CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugB swap >>query ; : yahoo-search ( search -- seq ) - query http-get* string>xml parse-yahoo ; + query http-get nip string>xml parse-yahoo ; diff --git a/extra/youtube/youtube.factor b/extra/youtube/youtube.factor index 900f01e2e6..fde9b05fd6 100644 --- a/extra/youtube/youtube.factor +++ b/extra/youtube/youtube.factor @@ -50,7 +50,7 @@ CONSTANT: video-info-url URL" http://www.youtube.com/get_video_info" "detailpage" "el" set-query-param "en_US" "hl" set-query-param swap "video_id" set-query-param - http-get* query>assoc ; + http-get nip query>assoc ; : video-formats ( video-info -- video-formats ) "url_encoded_fmt_stream_map" of "," split -- 2.34.1