From dc5e935ecd47485e9d29bb425c8b7c71288772c2 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Sun, 5 Dec 2021 17:28:00 +0100 Subject: [PATCH] use newly available predicates from library(tls) for HTTPS --- src/lib/http/http_open.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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, []). -- 2.54.0