From: Adrián Arroyo Calle Date: Sat, 17 Dec 2022 19:43:43 +0000 (+0100) Subject: Compatible Doclog docs for library(http/http_open). X-Git-Tag: v0.9.2~246^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=6a995fb62b02900d1958349be70f00c1dbaa9c10;p=scryer-prolog.git Compatible Doclog docs for library(http/http_open). --- diff --git a/src/lib/http/http_open.pl b/src/lib/http/http_open.pl index 1c89b5a5..7d0503c2 100644 --- a/src/lib/http/http_open.pl +++ b/src/lib/http/http_open.pl @@ -1,34 +1,37 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Written 2022 by Adrián Arroyo Calle (adrian.arroyocalle@gmail.com) Part of Scryer Prolog. +*/ - http_open(+Address, -Stream, +Options) - ====================================== +/** Make HTTP requests. - Yields Stream to read the body of an HTTP reply from Address. - Address is a list of characters, and includes the method. Both HTTP - and HTTPS are supported. - - Options supported: - - * method(+Method): Sets the HTTP method of the call. Method can be get (default), head, delete, post, put or patch. - * data(+Data): Data to be sent in the request. Useful for POST, PUT and PATCH operations. - * size(-Size): Unifies with the value of the Content-Length header - * request_headers(+RequestHeaders): Headers to be used in the request - * headers(-ListHeaders): Unifies with a list with all headers returned in the response - * status_code(-Code): Unifies with the status code of the request (200, 201, 404, ...) - - Example: - - ?- http_open("https://github.com/mthom/scryer-prolog", S, []). - %@ S = '$stream'(0x7fcfc9e00f00). - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +This library contains the predicate http\_open/3 which allows you to perform HTTP(S) calls. +Useful for making API calls, or parsing websites. It uses Hyper underneath. +*/ :- module(http_open, [http_open/3]). :- use_module(library(lists)). +%% http_open(+Address, -Stream, +Options). +% +% Yields Stream to read the body of an HTTP reply from Address. +% Address is a list of characters, and includes the method. Both HTTP +% and HTTPS are supported. +% +% Options supported: +% +% * `method(+Method)`: Sets the HTTP method of the call. Method can be `get` (default), `head`, `delete`, `post`, `put` or `patch`. +% * `data(+Data)`: Data to be sent in the request. Useful for POST, PUT and PATCH operations. +% * `size(-Size)`: Unifies with the value of the Content-Length header +% * `request_headers(+RequestHeaders)`: Headers to be used in the request +% * `headers(-ListHeaders)`: Unifies with a list with all headers returned in the response +% * `status_code(-Code)`: Unifies with the status code of the request (200, 201, 404, ...) +% +% Example: +% +% ?- http_open("https://www.example.com", S, []), get_n_chars(S, N, HTML). +% S = '$stream'(0x7fb548001be8), N = 1256, HTML = "\n true; Method = get), @@ -65,4 +68,4 @@ parse_http_options_(request_headers(Headers), request_headers(Headers)) :- parse_http_options_(size(Size), size(Size)). parse_http_options_(status_code(Code), status_code(Code)). -parse_http_options_(headers(Headers), headers(Headers)). \ No newline at end of file +parse_http_options_(headers(Headers), headers(Headers)).