]> Repositorios git - scryer-prolog.git/commitdiff
use newly available predicates from library(tls) for HTTPS
authorMarkus Triska <[email protected]>
Sun, 5 Dec 2021 16:28:00 +0000 (17:28 +0100)
committerMarkus Triska <[email protected]>
Sun, 5 Dec 2021 17:16:47 +0000 (18:16 +0100)
src/lib/http/http_open.pl

index 60e886089891ffae5a66293af59906b7ed7b7272..6d720f1b398a6dd07bd7dfd9a27c602f8769af99 100644 (file)
@@ -1,5 +1,5 @@
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-   Written June 2020 by Markus Triska ([email protected])
+   Written 2020, 2021 by Markus Triska ([email protected])
    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, []).