diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor index 5a622a21ab..3c908ee619 100644 --- a/basis/http/client/client-docs.factor +++ b/basis/http/client/client-docs.factor @@ -55,36 +55,78 @@ 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 } } { "response" response } { "data" sequence } } +{ $description "Downloads the contents of a URL, but does not check the HTTP response code for success." } ; + +{ http-get http-get* } related-words + 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 } } { "response" response } { "data" sequence } } +{ $description "Submits an HTTP POST request, but does not check the HTTP response code for success." } ; + +{ http-post http-post* } related-words + 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 } } { "response" response } { "data" sequence } } +{ $description "Submits an HTTP PUT request, but does not check the HTTP response code for success." } ; + +{ http-put http-put* } related-words + 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 } } { "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." } ; + +{ http-head http-head* } related-words + 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 } } { "response" response } { "data" sequence } } +{ $description "Requests that the origin server delete the resource identified by the URL, but does not check the HTTP response code for success." } ; + +{ http-delete http-delete* } related-words + 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 } } { "response" response } { "data" sequence } } +{ $description "Submits an HTTP OPTIONS request, but does not check the HTTP response code for success." } ; + +{ http-options http-options* } related-words + 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 } } { "response" response } { "data" sequence } } +{ $description "Submits an HTTP TRACE request, but does not check the HTTP response code for success." } ; + +{ http-trace http-trace* } related-words + HELP: http-request { $values { "request" request } { "response" response } { "data" sequence } } { $description "A variant of " { $link http-request* } " that checks that the response was successful." } @@ -108,6 +150,7 @@ 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* } "Utilities to retrieve a " { $link url } " and save the contents to a file:" { $subsections @@ -146,21 +189,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 } +{ $subsections http-post 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 } +{ $subsections http-put 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 } +{ $subsections http-head http-head* } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections @@ -168,7 +211,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 } +{ $subsections http-delete http-delete* } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections @@ -176,7 +219,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 } +{ $subsections http-options http-options* } "Advanced usage involves constructing a " { $link request } ", which allows " { $link "http.cookies" } " and " { $link "http.headers" } " to be set:" { $subsections @@ -185,7 +228,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 } +{ $subsections http-trace 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 5571f2c3ab..7f7d5bd379 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -177,6 +177,9 @@ ERROR: download-failed response ; : http-get ( url -- response data ) http-request ; +: http-get* ( url -- response data ) + http-request* ; + : download-name ( url -- name ) present file-name "?" split1 drop "/" ?tail drop ; @@ -195,6 +198,9 @@ ERROR: download-failed response ; : http-post ( post-data url -- response data ) http-request ; +: http-post* ( post-data url -- response data ) + http-request* ; + : ( post-data url -- request ) "PUT" swap >>post-data ; @@ -202,28 +208,43 @@ ERROR: download-failed response ; : http-put ( post-data url -- response data ) http-request ; +: http-put* ( post-data url -- response data ) + http-request* ; + : ( url -- request ) "DELETE" ; : http-delete ( url -- response data ) http-request ; +: http-delete* ( url -- response data ) + http-request* ; + : ( url -- request ) "HEAD" ; : http-head ( url -- response data ) http-request ; +: http-head* ( url -- response data ) + http-request* ; + : ( url -- request ) "OPTIONS" ; : http-options ( url -- response data ) http-request ; +: http-options* ( url -- response data ) + http-request* ; + : ( url -- request ) "TRACE" ; : http-trace ( url -- response data ) http-request ; +: http-trace* ( url -- response data ) + http-request* ; + { "http.client" "debugger" } "http.client.debugger" require-when