<p>CurlInterface allows a user to interact with http and https servers on the internet, using the 'curl' library. Pages can be downloaded from a URL, and http POST requests can be sent to the URL for processing.</p>
<p>curlInterface requires the 'curl' library, available from <span class="URL"><a href="https://curl.haxx.se/">https://curl.haxx.se/</a></span>. Instructions for building and installing curl can be found at <span class="URL"><a href="https://curl.haxx.se/docs/install.html">https://curl.haxx.se/docs/install.html</a></span>, however in most systems curl can be installed from your OS's package manager.
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DownloadURL</code>( <var class="Arg">URL</var>[, <var class="Arg">opts</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a record</p>
<p>Downloads a URL from the internet. <var class="Arg">URL</var> should be a string describing the address, and should start with either "http://" or "https://". For descriptions of the output and the additional argument <var class="Arg">opts</var>, see <code class="func">CurlRequest</code> (<a href="chap1.html#X79B1452982D2B19C"><span class="RefLink">1.2-4</span></a>).</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PostToURL</code>( <var class="Arg">URL</var>, <var class="Arg">str</var>[, <var class="Arg">opts</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a record</p>
<p>Sends an HTTP POST request to a URL on the internet. <var class="Arg">URL</var> should be a string describing the address, and should start with either "http://" or "https://". <var class="Arg">str</var> should be the string which will be sent to the server as a POST request. For descriptions of the output and the additional argument <var class="Arg">opts</var>, see <code class="func">CurlRequest</code> (<a href="chap1.html#X79B1452982D2B19C"><span class="RefLink">1.2-4</span></a>).</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DeleteURL</code>( <var class="Arg">URL</var>[, <var class="Arg">opts</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a record</p>
<p>Attempts to delete a file on the internet, by sending an HTTP DELETE request to the given URL. <var class="Arg">URL</var> should be a string describing the address to be deleted, and should start with either "http://" or "https://". For descriptions of the output and the additional argument <var class="Arg">opts</var>, see <code class="func">CurlRequest</code> (<a href="chap1.html#X79B1452982D2B19C"><span class="RefLink">1.2-4</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">r := DeleteURL("www.google.com");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">r.success;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">r.result{[1471..1540]};</span> "<p>The request method <code>DELETE</code> is inappropriate for the URL"
</pre></div>
<p>Sends an HTTP request of type <var class="Arg">type</var> to a URL on the internet. <var class="Arg">URL</var>, <var class="Arg">type</var>, and <var class="Arg">out_string</var> should all be strings: <var class="Arg">URL</var> is the URL of the server (which should start with "http://" or "https://"), <var class="Arg">type</var> is the type of HTTP request (e.g. "GET"), and <var class="Arg">out_string</var> is the message, if any, to send to the server (in requests such as GET this will be ignored).</p>
<p>An optional fourth argument <var class="Arg">opts</var> may be included, which should be a record specifying additional options for the request. The following options are supported:</p>
<ul>
<li><p><code class="code">verifyCert</code>: a boolean describing whether to verify HTTPS certificates (corresponds to the curl options <code class="code">CURLOPT_SSL_VERIFYPEER</code> and <code class="code">CURLOPT_SSL_VERIFYHOST</code>, the default is <code class="keyw">true</code> for both);</p>
</li>
<li><p><code class="code">verbose</code>: a boolean describing whether to print extra information to the screen (corresponds to the curl option <code class="code">CURLOPT_VERBOSE</code>, the default is <code class="keyw">false</code>);</p>
</li>
<li><p><code class="code">followRedirect</code>: a boolean describing whether to follow redirection to another URL (corresponds to the curl option <code class="code">CURLOPT_FOLLOWLOCATION</code>, the default is <code class="keyw">true</code>);</p>
</li>
<li><p><code class="code">failOnError</code>: a boolean describing whether to regard 404 (and other 4xx) status codes as error (corresponds to the curl option <code class="code">CURLOPT_FAILONERROR</code>, the default is <code class="keyw">false</code>).</p>
</li>
<li><p><code class="code">maxTime</code>: Maximum time in seconds that you allow each transfer to take. 0 means no limitation. (default <code class="keyw">0</code>).</p>
</li>
</ul>
<p>As output, this function returns a record containing some of the following components, which describe the outcome of the request:</p>
<ul>
<li><p><code class="code">success</code>: a boolean describing whether the request was successfully received by the server;</p>
</li>
<li><p><code class="code">result</code>: body of the information sent by the server (only if <code class="code">success = true</code>);</p>
</li>
<li><p><code class="code">error</code>: human-readable string saying what went wrong (only if <codeclass="code">success = false</code>).</p>
</li>
</ul>
<p>Most of the standard HTTP request types should work, but currently only body information is returned. To see headers, consider using the <code class="code">verbose</code> option. For convenience, dedicated functions exist for the following request types:</p>
<ul>
<li><p><code class="func">DownloadURL</code> (<a href="chap1.html#X7827F7DE85113D7E"><span class="RefLink">1.2-1</span></a>) for GET requests;</p>
</li>
<li><p><code class="func">PostToURL</code> (<a href="chap1.html#X81A7B7017D508BE9"><span class="RefLink">1.2-2</span></a>) for POST requests;</p>
</li>
<li><p><code class="func">DeleteURL</code> (<a href="chap1.html#X84C36A2D86B7975B"><span class="RefLink">1.2-3</span></a>) for DELETE requests.</p>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.