Like CHECK_VERSION, but the check for soup_check_version is at
runtime instead of compile time.
This is useful for compiling against older versions of libsoup, but using features from newer versions.
Passed: an unsigned 32-bit integer.
the major version to check
Passed: an unsigned 32-bit integer.
the minor version to check
Passed: an unsigned 32-bit integer.
the micro version to check
Returned: a boolean.
#t if the version of the libsoup currently loaded is the same as
or newer than the passed-in version.
Parses header and returns a Cookie.
If header contains multiple cookies, only the first one will be parsed.
If header does not have "path" or "domain" attributes, they will
be defaulted from origin. If origin is #f, path will
default to "/", but domain will be left as #f. Note that this is
not a valid state for a Cookie, and you will need to fill in some
appropriate string for the domain if you want to actually make use of
the cookie.
As of version 3.4.0 the default value of a cookie’s same-site-policy is
lax.
Passed: a string.
a cookie string (eg, the value of a Set-Cookie header)
Passed, or left out: a <GUri>, or #f.
origin of the cookie
Returned: a <SoupCookie>, or #f.
a new <SoupCookie>, or #f if it could not be
parsed, or contained an illegal "domain" attribute for a cookie
originating from origin.
Parses msg’s Cookie request header and returns a <GSList>
of <SoupCookie>s.
As the "Cookie" header, unlike "Set-Cookie", only contains cookie names
and values, none of the other Cookie fields will be filled in.
(Thus, you can’t generally pass a cookie returned from this method
directly to cookies_to_response.)
Passed: a <SoupMessage>.
a <SoupMessage> containing a "Cookie" request
header
Returned: a list, each a <SoupCookie>.
a GSList of <SoupCookie>s, which can be
freed with Cookie.free.
Parses msg’s Set-Cookie response headers and returns a
<GSList> of <SoupCookie>s.
Cookies that do not specify "path" or "domain" attributes will have their values defaulted from msg.
Passed: a <SoupMessage>.
a <SoupMessage> containing a "Set-Cookie" response
header
Returned: a list, each a <SoupCookie>.
a GSList of <SoupCookie>s, which can be
freed with Cookie.free.
Serializes a <GSList> of Cookie into a string suitable for
setting as the value of the "Cookie" header.
Passed: a list, each a <SoupCookie>.
a GSList of Cookie
Returned: a string.
the serialization of cookies
Adds the name and value of each cookie in cookies to msg’s "Cookie" request.
If msg already has a "Cookie" request header, these cookies will be appended to the cookies already present. Be careful that you do not append the same cookies twice, eg, when requeuing a message.
Passed: a list, each a <SoupCookie>.
a GSList of Cookie
Passed: a <SoupMessage>.
Appends a "Set-Cookie" response header to msg for each cookie in cookies.
This is in addition to any other "Set-Cookie" headers msg may already have.
Passed: a list, each a <SoupCookie>.
a GSList of Cookie
Passed: a <SoupMessage>.
Parses date-string and tries to extract a date from it.
This recognizes all of the "HTTP-date" formats from RFC 2616, RFC 2822 dates, and reasonable approximations thereof. (Eg, it is lenient about whitespace, leading "0"s, etc.)
Passed: a string.
The date as a string
Returned: a <GDateTime>, or #f.
a new <GDateTime>, or #f if
date-string could not be parsed.
Converts date to a string in the format described by format.
Passed: a <GDateTime>.
Passed: a <SoupDateFormat>, or one of its
symbols.
the format to generate the date in
Returned: a string.
date as a string or #f
Decodes form.
which is an urlencoded dataset as defined in the HTML 4.01 spec.
Passed: a string.
data of type "application/x-www-form-urlencoded"
Returned: a hash table, each key a string and each value a string.
a hash table containing the name/value pairs from encoded-form,
which you can free with hash-table:destroy.
Decodes the "multipart/form-data" request in multipart.
this is a convenience method for the case when you have a single file
upload control in a form. (Or when you don’t have any file upload
controls, but are still using "multipart/form-data" anyway.) Pass the
name of the file upload control in file-control-name, and
form_decode_multipart will extract the uploaded file data into
filename, content-type, and file. All of the other
form control data will be returned (as strings, as with
form_decode in the returned
<GHashTable>.
You may pass #f for filename, content-type and/or
file if you do not care about those fields.
form_decode_multipart may also return #f in those fields
if the client did not provide that information. You must free the
returned filename and content-type with
byte-array:free, and the returned file data with
Glib.Bytes.unref.
If you have a form with more than one file upload control, you will need
to decode it manually, using Multipart.new_from_message and
Multipart.get_part.
Passed: a <SoupMultipart>.
Passed, or left out: a string, or #f.
the name of the HTML file upload control
Returned: a hash table, each key a string and each value a string, or
#f.
a hash table containing the name/value pairs (other than
file-control-name) from msg, which you can free with
hash-table:destroy. On error, it
will return #f.
Returned: a string.
return location for the name of the uploaded file
Returned: a string.
return location for the MIME type of the uploaded file
Returned: a <GBytes>.
return location for the uploaded file data
Encodes form-data-set into a value of type "application/x-www-form-urlencoded".
Encodes as defined in the HTML 4.01 spec.
Note that the HTML spec states that "The control names/values are listed
in the order they appear in the document." Since this method takes a
hash table, it cannot enforce that; if you care about the ordering of
the form fields, use form_encode_datalist.
See also: Message.new_from_encoded_form.
Passed: a hash table, each key a string and each value a string.
a hash table containing name/value pairs (as strings)
Returned: a string.
the encoded form
Returns the major version number of the libsoup library.
e.g. in libsoup version 2.42.0 this is 2.
This function is in the library, so it represents the libsoup library
your code is running against. Contrast with the
SOUP_MAJOR_VERSION macro, which represents the major version of
the libsoup headers you have included when compiling your code.
Returned: an unsigned 32-bit integer.
the major version number of the libsoup library
Returns the micro version number of the libsoup library.
e.g. in libsoup version 2.42.0 this is 0.
This function is in the library, so it represents the libsoup library
your code is running against. Contrast with the
SOUP_MICRO_VERSION macro, which represents the micro version of
the libsoup headers you have included when compiling your code.
Returned: an unsigned 32-bit integer.
the micro version number of the libsoup library
Returns the minor version number of the libsoup library.
e.g. in libsoup version 2.42.0 this is 42.
This function is in the library, so it represents the libsoup library
your code is running against. Contrast with the
SOUP_MINOR_VERSION macro, which represents the minor version of
the libsoup headers you have included when compiling your code.
Returned: an unsigned 32-bit integer.
the minor version number of the libsoup library
Parses header to see if it contains the token token (matched case-insensitively).
Note that this can’t be used with lists that have qvalues.
Passed: a string.
An HTTP header suitable for parsing with header_parse_list
Passed: a string.
a token
Returned: a boolean.
whether or not header contains token
Frees param-list.
Passed: a hash table, each key a string and each value a string.
a <GHashTable> returned from
header_parse_param_list or header_parse_semi_param_list
Appends something like name=value to string, taking care to
quote value if needed, and if so, to escape any quotes or
backslashes in value.
Alternatively, if value is a non-ASCII UTF-8 string, it will be appended using RFC5987 syntax. Although in theory this is supposed to work anywhere in HTTP that uses this style of parameter, in reality, it can only be used portably with the Content-Disposition "filename" parameter.
If value is #f, this will just append name to
string.
Appends something like name="value" to string, taking care
to escape any quotes or backslashes in value.
If value is (non-ASCII) UTF-8, this will instead use RFC 5987
encoding, just like header_g_string_append_param.
Parses a header whose content is described by RFC2616 as
#something.
"something" does not itself contain commas, except as part of quoted-strings.
Passed: a string.
a header value
Returned: a list, each a string.
a GSList of list elements, as allocated strings
Parses a header which is a comma-delimited list of something like:
token [ "=" ( token | quoted-string ) ].
Tokens that don’t have an associated value will still be added to the
resulting hash table, but with a #f value.
This also handles RFC5987 encoding (which in HTTP is mostly used for giving UTF8-encoded filenames in the Content-Disposition header).
Passed: a string.
a header value
Returned: a hash table, each key a string and each value a string.
a <GHashTable> of list elements, which can
be freed with header_free_param_list.
A strict version of header_parse_param_list that bails out if
there are duplicate parameters.
Note that this function will treat RFC5987-encoded parameters as
duplicated if an ASCII version is also present. For header fields that
might contain RFC5987-encoded parameters, use
header_parse_param_list instead.
Passed: a string.
a header value
Returned: a hash table, each key a string and each value a string, or
#f.
a <GHashTable> of list elements, which can
be freed with header_free_param_list or #f if there are
duplicate elements.
Parses a header whose content is a list of items with optional "qvalue"s (eg, Accept, Accept-Charset, Accept-Encoding, Accept-Language, TE).
If unacceptable is not #f, then on return, it will contain
the items with qvalue 0. Either way, those items will be removed from
the main list.
Passed: a string.
a header value
Returned: a list, each a string.
a GSList of acceptable values (as allocated strings),
highest-qvalue first.
Returned: a list, each a string.
on return, will contain a list of unacceptable values
Parses a header which is a semicolon-delimited list of something like:
token [ "=" ( token | quoted-string ) ].
Tokens that don’t have an associated value will still be added to the
resulting hash table, but with a #f value.
This also handles RFC5987 encoding (which in HTTP is mostly used for giving UTF8-encoded filenames in the Content-Disposition header).
Passed: a string.
a header value
Returned: a hash table, each key a string and each value a string.
a <GHashTable> of list elements, which can
be freed with header_free_param_list.
A strict version of header_parse_semi_param_list that bails out
if there are duplicate parameters.
Note that this function will treat RFC5987-encoded parameters as
duplicated if an ASCII version is also present. For header fields that
might contain RFC5987-encoded parameters, use
header_parse_semi_param_list instead.
Passed: a string.
a header value
Returned: a hash table, each key a string and each value a string, or
#f.
a <GHashTable> of list elements, which can
be freed with header_free_param_list or #f if there are
duplicate elements.
Parses the headers of an HTTP request in str and stores the results in req-method, req-path, ver, and req-headers.
Beware that req-headers may be modified even on failure.
Passed: a string.
the headers (up to, but not including, the trailing blank line)
Passed: a 32-bit integer.
length of str
Passed: a <SoupMessageHeaders>.
<SoupMessageHeaders> to store the header
values in
Returned: an unsigned 32-bit integer.
ok if the headers could be parsed, or an HTTP error
to be returned to the client if they could not be.
Returned: a string.
if non-#f, will be filled in with the request method
Returned: a string.
if non-#f, will be filled in with the request path
Returned: a <SoupHTTPVersion>.
if non-#f, will be filled in with the HTTP version
Parses the headers of an HTTP response in str and stores the results in ver, status-code, reason-phrase, and headers.
Beware that headers may be modified even on failure.
Passed: a string.
the headers (up to, but not including, the trailing blank line)
Passed: a 32-bit integer.
length of str
Passed: a <SoupMessageHeaders>.
<SoupMessageHeaders> to store the header
values in
Returned: a boolean.
success or failure.
Returned: a <SoupHTTPVersion>.
if non-#f, will be filled in with the HTTP version
Returned: an unsigned 32-bit integer.
if non-#f, will be filled in with the status code
Returned: a string.
if non-#f, will be filled in with the reason phrase
Parses the HTTP Status-Line string in status-line into ver, status-code, and reason-phrase.
status-line must be terminated by either "\0" or "\r\n".
Passed: a string.
an HTTP Status-Line
Returned: a boolean.
#t if status-line was parsed successfully.
Returned: a <SoupHTTPVersion>.
if non-#f, will be filled in with the HTTP version
Returned: an unsigned 32-bit integer.
if non-#f, will be filled in with the status code
Returned: a string.
if non-#f, will be filled in with the reason phrase
Parses the headers of an HTTP request or response in str and stores the results in dest.
Beware that dest may be modified even on failure.
This is a low-level method; normally you would use
headers_parse_request or headers_parse_response.
Passed: a string.
the header string (including the Request-Line or Status-Line, but not the trailing blank line)
Passed: a 32-bit integer.
length of str
Passed: a <SoupMessageHeaders>.
<SoupMessageHeaders> to store the header
values in
Returned: a boolean.
success or failure
Registers error quark for SoupSession if needed.
Returned: an unsigned 32-bit integer.
Error quark for SoupSession.
Looks up the stock HTTP description of status-code.
There is no reason for you to ever use this function. If you
wanted the textual description for the Message:status-code of a
given Message, you should just look at the message’s
Message:reason-phrase. However, you should only do that for use
in debugging messages; HTTP reason phrases are not localized, and are
not generally very descriptive anyway, and so they should never be
presented to the user directly. Instead, you should create you own
error messages based on the status code, and on what you were trying to
do.
Passed: an unsigned 32-bit integer.
an HTTP status code
Returned: a string.
the (terse, English) description of status-code
Looks whether the domain passed as argument is a public domain suffix (.org, .com, .co.uk, etc) or not.
Prior to libsoup 2.46, this function required that domain be in UTF-8 if it was an IDN. From 2.46 on, the name can be in either UTF-8 or ASCII format.
Passed: a string.
a domain name
Returned: a boolean.
#t if it is a public domain, #f otherwise.
Registers error quark for
tld-get-base-domain if needed.
Returned: an unsigned 32-bit integer.
Error quark for Soup TLD functions.
Finds the base domain for a given hostname
The base domain is composed by the top level domain (such as .org, .com, .co.uk, etc) plus the second level domain, for example for myhost.mydomain.com it will return mydomain.com.
Note that #f will be returned for private URLs (those not ending
with any well known TLD) because choosing a base domain for them would
be totally arbitrary.
Prior to libsoup 2.46, this function required that hostname be in UTF-8 if it was an IDN. From 2.46 on, the name can be in either UTF-8 or ASCII format (and the return value will be in the same format).
Passed: a string.
a hostname
Returned: a string.
a pointer to the start of the base domain in hostname. If an
error occurs, #f will be returned and error set.
Decodes the given data URI and returns its contents and content-type.
Tests whether or not uri1 and uri2 are equal in all parts.
Registers error quark for SoupWebsocket if needed.
Returned: an unsigned 32-bit integer.
Error quark for SoupWebsocket.