If you want to make crypo transparent, you should extend the support
for URLs in SWI-Prolog. This is like the end-user view of crypto, and
not the developer view of crypto.
So it would address the need for those who for example just want
to establish a connection to a HTTPS web site without much husse.
I doubt that we need an extra open/[3,4] for that.
I have aready promoted extending ISO core Prolog streams to also
support all kind of connections for a while. I remember discussions
with Logtalk, why we would then drop the requirement that
stream_property really keeps a table of all connections. But maybe
different design considerations are possible. Last week I figured out,
that absolute_file_name/[2,3] can be used to let a web site normalize
paths, and make visible when a HTTPS connection is requested.
This does not (yet?) work in SWI-Prolog I only get:
?- absolute_file_name('
http://blick.ch/robots.txt', X).
X = 'c:/users/jan burse/documents/prolog/http:/
blick.ch/robots.txt'.
On the other hand for the upcoming release of Jekejeke Prolog I have:
?- absolute_file_name('http://blick.ch/robots.txt', X).
X = 'https://www.blick.ch/robots.txt'
Note the magic that happend (by virtue of the HTTP 301 code):
- The host was automatically prefixed by 'www.'
- The protocol was automatically changed from 'http:' to 'https:'
This is a very nice canonization without the use of an other infrastructure
from the internet, namely the domain name server infrastructure. Because
this infrastructure usually yields nonsense for a web server:
I guess the nonsense happens because of modern CDN technique,
a fact that I had to learn last weak also.
?- use_module(library(system/domain)).
% 1 consults and 0 unloads in 16 ms.
Yes
?- host_lookup('blick.ch', X).
X = '37.58.62.60'
?- host_lookup(X, '37.58.62.60').
X = '37.58.62.60'
?- host_lookup('www.blick.ch', X).
X = '23.211.6.46'
?- host_lookup(X, '23.211.6.46').
X = 'a23-211-6-46.deploy.static.akamaitechnologies.com'
For the end-user, extending the absolute_file_name to URLs
is very comfortabke. For example then reading a HTTPS web
site works as easily as:
?- open('
http://blick.ch/robots.txt', read, X, [alias(test)]).
X = 0r4bc68116
?- read_line(test, X).
X = 'User-agent: * '
?- close(test).
Yes
See also my blog post here:
https://plus.google.com/+JekejekeCh/posts/7f3Av1mruKwDisclaimer: This realization wasn't planned. I was first
researching into Puny code. But this web server based to
find normal URLs is very welcome.
By the approach of just using the ISO core Prolog API, I
spare additional predicates such as for example http_open/3.
I could add all the http_open/3 options to open/[3,4] as well.
I did the following test here (providing a HTTP URL which
will be redirected to a HTTPS URL):
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.0-rc1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
?- use_module(library(http/http_open)).
true.
ᄀ?- use_module(library(http/http_ssl_plugin)).
ERROR: c:/program files/swipl/library/
crypto.pl:68:
c:/program files/swipl/library/
crypto.pl:68: Initialization goal raised exception:
'$open_shared_object'/3: Das angegebene Modul wurde nicht gefunden.
?- http_open('
http://blick.ch', X, []).
ERROR: Undefined procedure: ssl:'_ssl_context'/4
ERROR: However, there are definitions for:
ERROR: ssl:ssl_context/3
But after the first error it probably didn't make any sense to
continue testing. Is the SSL plugin not supported on Windows?
Or is this a smal problem of the release version 7.6.0-rc1 I was using?
I was using this recommendation here:
http://www.swi-prolog.org/pldoc/man?section=ssl-https-clientBut I don't know whether there is a recommendation to
get the redirected URL before actually establishing the connection.
Is this possible?