2.2.2 Option Data Types

In the options table there are several possible types listed for the option info argument:

boolean

#t or #f

integer

A long integer. Note that many options have named integer-valued constants defined.

biginteger

An integer that is possibly longer than a long integer.

string

A string. The scheme string is converted to a C string encoded in the current locale.

bytevector

Either a bytevector or a string that only contains the Unicode code points U+0000 through U+00FF.

blob

A bytevector, or a string that only contains the Unicode code points U+0000 through U+00FF, holding data such as a certificate or a key in memory. libcurl copies it, so it may be changed after the option is set. An empty bytevector or string clears the option.

input port

An input port from which the data to upload is read, for example after setting the upload option. The port is read while the transfer runs; guile-curl keeps it from being garbage collected while the handle uses it.

slist

A list containing zero or more strings. The scheme string is converted to a C string encoded in the current locale.

mimepost

A list of fields for a multipart/form-data form, such as an HTML form posted over HTTP. Setting it makes the request a POST that sends the form. It is built with libcurl’s MIME API (curl_mime_init and related functions) and passed as CURLOPT_MIMEPOST.

The fields are sent in the order in which they appear in the list. An empty list clears any form set before.

Each field is itself a list of two required and two optional elements:

  1. The name of the field [required string]
  2. The data of the field [required bytevector]
  3. The MIME type of the data, sent as the field’s Content-Type [optional string]
  4. A filename [optional string]. The field is then sent as a file upload with that filename, with the data as the file’s contents; no file is read from disk.

The string and bytevector types are as described above. The data may contain any bytes, including NUL; the name, MIME type and filename may not contain the NUL character. libcurl copies all of them, so they may be changed after the option is set.

For example, this sends a text field and a file named notes.txt:

(curl-easy-setopt handle 'mimepost
                  '(("title" "Meeting notes")
                    ("upload" "First line\nSecond line\n"
                     "text/plain" "notes.txt")))

Before version 1.0.0 this option was called httppost and was passed as CURLOPT_HTTPPOST, using libcurl’s deprecated curl_formadd API. httppost is still accepted as another name for mimepost: it takes the same list of fields and sends exactly the same request, built with the MIME API. New code should use mimepost.

In guile-curl 0.10 and earlier, a form given with httppost was never actually sent, because of a bug. Programs that set it relying on that will now send their form as a multipart/form-data POST.