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:
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.
% 1 consults and 0 unloads in 16 ms.
?- host_lookup('blick.ch', X).
X = '22.214.171.124'
?- host_lookup(X, '126.96.36.199').
X = '188.8.131.52'
?- host_lookup('www.blick.ch', X).
X = '184.108.40.206'
?- host_lookup(X, '220.127.116.11').
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:
', read, X, [alias(test)]).
X = 0r4bc68116
?- read_line(test, X).
X = 'User-agent: * '
See also my blog post here:https://plus.google.com/+JekejekeCh/posts/7f3Av1mruKw
Disclaimer: 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.
ERROR: c:/program files/swipl/library/crypto.pl:68
: Initialization goal raised exception:
'$open_shared_object'/3: Das angegebene Modul wurde nicht gefunden.
', X, ).
ERROR: Undefined procedure: ssl:'_ssl_context'/4
ERROR: However, there are definitions for:
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-client
But I don't know whether there is a recommendation to
get the redirected URL before actually establishing the connection.
Is this possible?