  
  [1X1 [33X[0;0YOverview[133X[101X
  
  [33X[0;0YCurlInterface  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.[133X
  
  
  [1X1.1 [33X[0;0YInstalling curlInterface[133X[101X
  
  [33X[0;0YcurlInterface     requires    the    'curl'    library,    available    from
  [7Xhttps://curl.haxx.se/[107X.  Instructions for building and installing curl can be
  found  at  [7Xhttps://curl.haxx.se/docs/install.html[107X,  however  in most systems
  curl can be installed from your OS's package manager.[133X
  
  
  [1X1.1-1 [33X[0;0YLinux[133X[101X
  
  [30X    [33X[0;6YOn Debian and Ubuntu, call: [10Xapt-get install libcurl4-gnutls-dev[110X[133X
  
  [30X    [33X[0;6YOn Redhat and derivatives, call: [10Xyum install curl-devel[110X[133X
  
  
  [1X1.1-2 [33X[0;0YCygwin[133X[101X
  
  [33X[0;0YInstall [10Xlibcurl-devel[110X from the cygwin package manager[133X
  
  
  [1X1.1-3 [33X[0;0YmacOS[133X[101X
  
  [33X[0;0Ycurl is installed by default on Macs, but libcurl may be required.[133X
  
  [30X    [33X[0;6YHomebrew: [10Xbrew install curl[110X[133X
  
  [30X    [33X[0;6YFink: [10Xfink install libcurl4[110X[133X
  
  [30X    [33X[0;6YMacPorts: [10Xport install curl[110X[133X
  
  
  [1X1.2 [33X[0;0YFunctions[133X[101X
  
  [33X[0;0YcurlInterface  currently  provides  the  following functions for interacting
  with URLs:[133X
  
  [1X1.2-1 DownloadURL[101X
  
  [33X[1;0Y[29X[2XDownloadURL[102X( [3XURL[103X[, [3Xopts[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Ya record[133X
  
  [33X[0;0YDownloads  a  URL  from  the internet. [3XURL[103X should be a string describing the
  address,   and  should  start  with  either  "http://"  or  "https://".  For
  descriptions of the output and the additional argument [3Xopts[103X, see [2XCurlRequest[102X
  ([14X1.2-4[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr := DownloadURL("www.gap-system.org");;[127X[104X
    [4X[25Xgap>[125X [27Xr.success;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xr.result{[1..50]};[127X[104X
    [4X[28X"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!DOCTYPE "[128X[104X
  [4X[32X[104X
  
  [1X1.2-2 PostToURL[101X
  
  [33X[1;0Y[29X[2XPostToURL[102X( [3XURL[103X, [3Xstr[103X[, [3Xopts[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Ya record[133X
  
  [33X[0;0YSends  an HTTP POST request to a URL on the internet. [3XURL[103X should be a string
  describing   the   address,  and  should  start  with  either  "http://"  or
  "https://".  [3Xstr[103X  should be the string which will be sent to the server as a
  POST  request.  For  descriptions  of the output and the additional argument
  [3Xopts[103X, see [2XCurlRequest[102X ([14X1.2-4[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr := PostToURL("www.httpbin.org/post", "animal=tiger");;[127X[104X
    [4X[25Xgap>[125X [27Xr.success;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xr.result{[51..100]};[127X[104X
    [4X[28X"\"form\": {\n    \"animal\": \"tiger\"\n  }, \n  \"headers\":"[128X[104X
  [4X[32X[104X
  
  [1X1.2-3 DeleteURL[101X
  
  [33X[1;0Y[29X[2XDeleteURL[102X( [3XURL[103X[, [3Xopts[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Ya record[133X
  
  [33X[0;0YAttempts to delete a file on the internet, by sending an HTTP DELETE request
  to  the  given  URL.  [3XURL[103X  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 [3Xopts[103X, see [2XCurlRequest[102X
  ([14X1.2-4[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr := DeleteURL("www.google.com");;[127X[104X
    [4X[25Xgap>[125X [27Xr.success;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xr.result{[1471..1540]};[127X[104X
    [4X[28X"<p>The request method <code>DELETE</code> is inappropriate for the URL"[128X[104X
  [4X[32X[104X
  
  [1X1.2-4 CurlRequest[101X
  
  [33X[1;0Y[29X[2XCurlRequest[102X( [3XURL[103X, [3Xtype[103X, [3Xout_string[103X[, [3Xopts[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Ya record[133X
  
  [33X[0;0YSends  an HTTP request of type [3Xtype[103X to a URL on the internet. [3XURL[103X, [3Xtype[103X, and
  [3Xout_string[103X should all be strings: [3XURL[103X is the URL of the server (which should
  start  with "http://" or "https://"), [3Xtype[103X is the type of HTTP request (e.g.
  "GET"),  and  [3Xout_string[103X  is  the message, if any, to send to the server (in
  requests such as GET this will be ignored).[133X
  
  [33X[0;0YAn  optional  fourth argument [3Xopts[103X may be included, which should be a record
  specifying  additional  options  for  the request. The following options are
  supported:[133X
  
  [30X    [33X[0;6Y[10XverifyCert[110X:  a boolean describing whether to verify HTTPS certificates
        (corresponds   to   the   curl   options   [10XCURLOPT_SSL_VERIFYPEER[110X  and
        [10XCURLOPT_SSL_VERIFYHOST[110X, the default is [9Xtrue[109X for both);[133X
  
  [30X    [33X[0;6Y[10Xverbose[110X:  a  boolean  describing whether to print extra information to
        the  screen  (corresponds  to  the  curl  option  [10XCURLOPT_VERBOSE[110X, the
        default is [9Xfalse[109X);[133X
  
  [30X    [33X[0;6Y[10XfollowRedirect[110X:  a boolean describing whether to follow redirection to
        another  URL  (corresponds  to the curl option [10XCURLOPT_FOLLOWLOCATION[110X,
        the default is [9Xtrue[109X);[133X
  
  [30X    [33X[0;6Y[10XfailOnError[110X:  a  boolean  describing  whether to regard 404 (and other
        4xx)   status   codes   as  error  (corresponds  to  the  curl  option
        [10XCURLOPT_FAILONERROR[110X, the default is [9Xfalse[109X).[133X
  
  [33X[0;0YAs  output,  this function returns a record containing some of the following
  components, which describe the outcome of the request:[133X
  
  [30X    [33X[0;6Y[10Xsuccess[110X:  a  boolean  describing  whether the request was successfully
        received by the server;[133X
  
  [30X    [33X[0;6Y[10Xresult[110X:  body of the information sent by the server (only if [10Xsuccess =
        true[110X);[133X
  
  [30X    [33X[0;6Y[10Xerror[110X: human-readable string saying what went wrong (only if [10Xsuccess =
        false[110X).[133X
  
  [33X[0;0YMost of the standard HTTP request types should work, but currently only body
  information  is returned. To see headers, consider using the [10Xverbose[110X option.
  For convenience, dedicated functions exist for the following request types:[133X
  
  [30X    [33X[0;6Y[2XDownloadURL[102X ([14X1.2-1[114X) for GET requests;[133X
  
  [30X    [33X[0;6Y[2XPostToURL[102X ([14X1.2-2[114X) for POST requests;[133X
  
  [30X    [33X[0;6Y[2XDeleteURL[102X ([14X1.2-3[114X) for DELETE requests.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr := CurlRequest("https://www.google.com",[127X[104X
    [4X[25X>[125X [27X                    "HEAD",[127X[104X
    [4X[25X>[125X [27X                    "",[127X[104X
    [4X[25X>[125X [27X                    rec(verifyCert := false));[127X[104X
    [4X[28Xrec( result := "", success := true )[128X[104X
    [4X[25Xgap>[125X [27Xr := CurlRequest("www.httpbin.org/post", "POST", "animal=tiger");;[127X[104X
    [4X[25Xgap>[125X [27Xr.success;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xr.result{[51..100]};[127X[104X
    [4X[28X"\"form\": {\n    \"animal\": \"tiger\"\n  }, \n  \"headers\":"[128X[104X
  [4X[32X[104X
  
