From: Markus Triska Date: Sun, 5 Dec 2021 16:28:00 +0000 (+0100) Subject: use newly available predicates from library(tls) for HTTPS X-Git-Tag: v0.9.0~4^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=dc5e935ecd47485e9d29bb425c8b7c71288772c2;p=scryer-prolog.git use newly available predicates from library(tls) for HTTPS --- diff --git a/src/lib/http/http_open.pl b/src/lib/http/http_open.pl index 60e88608..6d720f1b 100644 --- a/src/lib/http/http_open.pl +++ b/src/lib/http/http_open.pl @@ -1,5 +1,5 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Written June 2020 by Markus Triska (triska@metalevel.at) + Written 2020, 2021 by Markus Triska (triska@metalevel.at) Part of Scryer Prolog. http_open(+Address, -Stream, +Options) @@ -29,6 +29,7 @@ :- use_module(library(charsio)). :- use_module(library(dcgs)). :- use_module(library(lists), [member/2]). +:- use_module(library(tls)). http_open(Address, Stream, Options) :- must_be(list, Options), @@ -74,7 +75,10 @@ chars_host_url(Cs, Host, [/|Us]) :- atom_chars(Host, Hs). connect(https, Host, Stream) :- - socket_client_open(Host:443, Stream, [tls(true)]). + socket_client_open(Host:443, Stream0, []), + atom_chars(Host, HostChars), + tls_client_context(Context, [hostname(HostChars)]), + tls_client_negotiate(Context, Stream0, Stream). connect(http, Host, Stream) :- socket_client_open(Host:80, Stream, []).