% This LaTeX document was generated using the LaTeX backend of PlDoc, % The SWI-Prolog documentation system \subsection{library(http/http_open): HTTP client library} \label{sec:httpopen} \begin{tags} \mtag{See also}- \predref{load_html}{3} and \predref{xpath}{3} can be used to parse and navigate HTML documents. \\- \predref{http_get}{3} and \predref{http_post}{4} provide an alternative interface that convert the reply depending on the \verb$Content-Type$ header. \end{tags} This library defines \predref{http_open}{3}, which opens an URL as a Prolog stream. The functionality of the library can be extended by loading two additional modules that act as plugins: \begin{description} \termitem{library}{http/http_ssl_plugin} Loading this library causes \predref{http_open}{3} to handle HTTPS connections. Relevant options for SSL certificate handling are handed to \predref{ssl_context}{3}. This plugin is loaded automatically if the scheme \const{https} is requested using a default SSL context. See the plugin for additional information regarding security. \termitem{library}{zlib} Loading this library supports the \const{gzip} transfer encoding. This plugin is lazily loaded if a connection is opened that claims this transfer encoding. \termitem{library}{http/http_cookie} Loading this library adds tracking cookies to \predref{http_open}{3}. Returned cookies are collected in the Prolog database and supplied for subsequent requests. \termitem{library}{http/http_stream} This library adds support for \textit{chunked} encoding. It is lazily loaded if the server sends a \verb$Transfer-encoding: chunked$ header. \end{description} Here is a simple example to fetch a web-page: \begin{code} ?- http_open('http://www.google.com/search?q=prolog', In, []), copy_stream_data(In, user_output), close(In). prolog - Google Search