@react-gnome/gjs-esm-types
Version:
TypeScript module declarations for GJS ESM modules.
1,596 lines (1,571 loc) • 366 kB
TypeScript
/*
* Type Definitions for Gjs (https://gjs.guide/)
*
* These type definitions are automatically generated, do not edit them by hand.
* If you found a bug fix it in ts-for-gir itself or create a bug report on https://github.com/gjsify/ts-for-gjs
*/
import type Gio from "gi://Gio?version=2.0";
import type GObject from "gi://GObject?version=2.0";
import type GLib from "gi://GLib?version=2.0";
declare module "gi://Soup?version=3.0" {
/**
* The type of cache; this affects what kinds of responses will be
* saved.
*/
enum CacheType {
/**
* a single-user cache
*/
SINGLE_USER,
/**
* a shared cache
*/
SHARED,
}
/**
* The policy for accepting or rejecting cookies returned in
* responses.
*/
enum CookieJarAcceptPolicy {
/**
* accept all cookies unconditionally.
*/
ALWAYS,
/**
* reject all cookies unconditionally.
*/
NEVER,
/**
* accept all cookies set by the main
* document loaded in the application using libsoup. An example of the most
* common case, web browsers, would be: If http://www.example.com is the page
* loaded, accept all cookies set by example.com, but if a resource from
* http://www.third-party.com is loaded from that page reject any cookie that
* it could try to set. For libsoup to be able to tell apart first party
* cookies from the rest, the application must call
* [method`Message`.set_first_party] on each outgoing [class`Message]`, setting
* the [struct`GLib`.Uri] of the main document. If no first party is set in a
* message when this policy is in effect, cookies will be assumed to be third
* party by default.
*/
NO_THIRD_PARTY,
/**
* accept all cookies set by
* the main document loaded in the application using libsoup, and from domains
* that have previously set at least one cookie when loaded as the main
* document. An example of the most common case, web browsers, would be: if
* http://www.example.com is the page loaded, accept all cookies set by
* example.com, but if a resource from http://www.third-party.com is loaded
* from that page, reject any cookie that it could try to set unless it
* already has a cookie in the cookie jar. For libsoup to be able to tell
* apart first party cookies from the rest, the application must call
* [method`Message`.set_first_party] on each outgoing #SoupMessage, setting the
* [struct`GLib`.Uri] of the main document. If no first party is set in a
* message when this policy is in effect, cookies will be assumed to be third
* party by default.
*/
GRANDFATHERED_THIRD_PARTY,
}
/**
* Date formats that [func`date_time_to_string]` can use.
*
* `SOUP_DATE_HTTP` and `SOUP_DATE_COOKIE` always coerce the time to
* UTC.
*
* This enum may be extended with more values in future releases.
*/
enum DateFormat {
/**
* RFC 1123 format, used by the HTTP "Date" header. Eg
* "Sun, 06 Nov 1994 08:49:37 GMT".
*/
HTTP,
/**
* The format for the "Expires" timestamp in the
* Netscape cookie specification. Eg, "Sun, 06-Nov-1994 08:49:37 GMT".
*/
COOKIE,
}
/**
* How a message body is encoded for transport
*/
enum Encoding {
/**
* unknown / error
*/
UNRECOGNIZED,
/**
* no body is present (which is not the same as a
* 0-length body, and only occurs in certain places)
*/
NONE,
/**
* Content-Length encoding
*/
CONTENT_LENGTH,
/**
* Response body ends when the connection is closed
*/
EOF,
/**
* chunked encoding (currently only supported
* for response)
*/
CHUNKED,
/**
* multipart/byteranges (Reserved for future
* use: NOT CURRENTLY IMPLEMENTED)
*/
BYTERANGES,
}
/**
* Indicates the HTTP protocol version being used.
*/
enum HTTPVersion {
/**
* HTTP 1.0 (RFC 1945)
*/
HTTP_1_0,
/**
* HTTP 1.1 (RFC 2616)
*/
HTTP_1_1,
/**
* HTTP 2.0 (RFC 7540)
*/
HTTP_2_0,
}
/**
* Describes the level of logging output to provide.
*/
enum LoggerLogLevel {
/**
* No logging
*/
NONE,
/**
* Log the Request-Line or Status-Line and
* the Soup-Debug pseudo-headers
*/
MINIMAL,
/**
* Log the full request/response headers
*/
HEADERS,
/**
* Log the full headers and request/response bodies
*/
BODY,
}
/**
* The lifetime of the memory being passed.
*/
enum MemoryUse {
/**
* The memory is statically allocated and
* constant; libsoup can use the passed-in buffer directly and not
* need to worry about it being modified or freed.
*/
STATIC,
/**
* The caller has allocated the memory and libsoup
* will assume ownership of it and free it with [func`GLib`.free].
*/
TAKE,
/**
* The passed-in data belongs to the caller and
* libsoup will copy it into new memory leaving the caller free
* to reuse the original memory.
*/
COPY,
}
/**
* Value passed to [ctor`MessageHeaders`.new] to set certain default
* behaviors.
*/
enum MessageHeadersType {
/**
* request headers
*/
REQUEST,
/**
* response headers
*/
RESPONSE,
/**
* multipart body part headers
*/
MULTIPART,
}
/**
* Priorities that can be set on a [class`Message]` to instruct the message queue
* to process it before any other message with lower priority.
*/
enum MessagePriority {
/**
* The lowest priority, the messages
* with this priority will be the last ones to be attended.
*/
VERY_LOW,
/**
* Use this for low priority messages, a
* #SoupMessage with the default priority will be processed first.
*/
LOW,
/**
* The default priotity, this is the
* priority assigned to the #SoupMessage by default.
*/
NORMAL,
/**
* High priority, a #SoupMessage with
* this priority will be processed before the ones with the default
* priority.
*/
HIGH,
/**
* The highest priority, use this
* for very urgent #SoupMessage as they will be the first ones to be
* attended.
*/
VERY_HIGH,
}
/**
* Represents the same-site policies of a cookie.
*/
enum SameSitePolicy {
/**
* The cookie is exposed with both cross-site and same-site requests
*/
NONE,
/**
* The cookie is withheld on cross-site requests but exposed on cross-site navigations
*/
LAX,
/**
* The cookie is only exposed for same-site requests
*/
STRICT,
}
/**
* A #SoupSession error.
*/
enum SessionError {
/**
* the server's response could not
* be parsed
*/
PARSING,
/**
* the server's response was in an
* unsupported format
*/
ENCODING,
/**
* the message has been redirected
* too many times
*/
TOO_MANY_REDIRECTS,
/**
* the message has been restarted
* too many times
*/
TOO_MANY_RESTARTS,
/**
* failed to redirect message because
* Location header was missing or empty in response
*/
REDIRECT_NO_LOCATION,
/**
* failed to redirect message because
* Location header contains an invalid URI
*/
REDIRECT_BAD_URI,
/**
* the message is already in the
* session queue. Messages can only be reused after unqueued.
*/
MESSAGE_ALREADY_IN_QUEUE,
}
/**
* These represent the known HTTP status code values, plus various
* network and internal errors.
*
* Note that no libsoup functions take or return this type directly;
* any function that works with status codes will accept unrecognized
* status codes as well.
*/
enum Status {
/**
* No status available. (Eg, the message has not
* been sent yet)
*/
NONE,
/**
* 100 Continue (HTTP)
*/
CONTINUE,
/**
* 101 Switching Protocols (HTTP)
*/
SWITCHING_PROTOCOLS,
/**
* 102 Processing (WebDAV)
*/
PROCESSING,
/**
* 200 Success (HTTP). Also used by many lower-level
* soup routines to indicate success.
*/
OK,
/**
* 201 Created (HTTP)
*/
CREATED,
/**
* 202 Accepted (HTTP)
*/
ACCEPTED,
/**
* 203 Non-Authoritative Information
* (HTTP)
*/
NON_AUTHORITATIVE,
/**
* 204 No Content (HTTP)
*/
NO_CONTENT,
/**
* 205 Reset Content (HTTP)
*/
RESET_CONTENT,
/**
* 206 Partial Content (HTTP)
*/
PARTIAL_CONTENT,
/**
* 207 Multi-Status (WebDAV)
*/
MULTI_STATUS,
/**
* 300 Multiple Choices (HTTP)
*/
MULTIPLE_CHOICES,
/**
* 301 Moved Permanently (HTTP)
*/
MOVED_PERMANENTLY,
/**
* 302 Found (HTTP)
*/
FOUND,
/**
* 302 Moved Temporarily (old name,
* RFC 2068)
*/
MOVED_TEMPORARILY,
/**
* 303 See Other (HTTP)
*/
SEE_OTHER,
/**
* 304 Not Modified (HTTP)
*/
NOT_MODIFIED,
/**
* 305 Use Proxy (HTTP)
*/
USE_PROXY,
/**
* 306 [Unused] (HTTP)
*/
NOT_APPEARING_IN_THIS_PROTOCOL,
/**
* 307 Temporary Redirect (HTTP)
*/
TEMPORARY_REDIRECT,
/**
* 308 Permanent Redirect (HTTP)
*/
PERMANENT_REDIRECT,
/**
* 400 Bad Request (HTTP)
*/
BAD_REQUEST,
/**
* 401 Unauthorized (HTTP)
*/
UNAUTHORIZED,
/**
* 402 Payment Required (HTTP)
*/
PAYMENT_REQUIRED,
/**
* 403 Forbidden (HTTP)
*/
FORBIDDEN,
/**
* 404 Not Found (HTTP)
*/
NOT_FOUND,
/**
* 405 Method Not Allowed (HTTP)
*/
METHOD_NOT_ALLOWED,
/**
* 406 Not Acceptable (HTTP)
*/
NOT_ACCEPTABLE,
/**
* 407 Proxy Authentication
* Required (HTTP)
*/
PROXY_AUTHENTICATION_REQUIRED,
/**
* shorter alias for
* %SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED
*/
PROXY_UNAUTHORIZED,
/**
* 408 Request Timeout (HTTP)
*/
REQUEST_TIMEOUT,
/**
* 409 Conflict (HTTP)
*/
CONFLICT,
/**
* 410 Gone (HTTP)
*/
GONE,
/**
* 411 Length Required (HTTP)
*/
LENGTH_REQUIRED,
/**
* 412 Precondition Failed (HTTP)
*/
PRECONDITION_FAILED,
/**
* 413 Request Entity Too Large
* (HTTP)
*/
REQUEST_ENTITY_TOO_LARGE,
/**
* 414 Request-URI Too Long (HTTP)
*/
REQUEST_URI_TOO_LONG,
/**
* 415 Unsupported Media Type
* (HTTP)
*/
UNSUPPORTED_MEDIA_TYPE,
/**
* 416 Requested Range
* Not Satisfiable (HTTP)
*/
REQUESTED_RANGE_NOT_SATISFIABLE,
/**
* shorter alias for
* %SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE
*/
INVALID_RANGE,
/**
* 417 Expectation Failed (HTTP)
*/
EXPECTATION_FAILED,
/**
* 421 Misdirected Request
*/
MISDIRECTED_REQUEST,
/**
* 422 Unprocessable Entity
* (WebDAV)
*/
UNPROCESSABLE_ENTITY,
/**
* 423 Locked (WebDAV)
*/
LOCKED,
/**
* 424 Failed Dependency (WebDAV)
*/
FAILED_DEPENDENCY,
/**
* 500 Internal Server Error
* (HTTP)
*/
INTERNAL_SERVER_ERROR,
/**
* 501 Not Implemented (HTTP)
*/
NOT_IMPLEMENTED,
/**
* 502 Bad Gateway (HTTP)
*/
BAD_GATEWAY,
/**
* 503 Service Unavailable (HTTP)
*/
SERVICE_UNAVAILABLE,
/**
* 504 Gateway Timeout (HTTP)
*/
GATEWAY_TIMEOUT,
/**
* 505 HTTP Version Not
* Supported (HTTP)
*/
HTTP_VERSION_NOT_SUPPORTED,
/**
* 507 Insufficient Storage
* (WebDAV)
*/
INSUFFICIENT_STORAGE,
/**
* 510 Not Extended (RFC 2774)
*/
NOT_EXTENDED,
}
/**
* Error codes for %SOUP_TLD_ERROR.
*/
enum TLDError {
/**
* A hostname was syntactically
* invalid.
*/
INVALID_HOSTNAME,
/**
* The passed-in "hostname" was
* actually an IP address (and thus has no base domain or
* public suffix).
*/
IS_IP_ADDRESS,
/**
* The passed-in hostname
* did not have enough components. Eg, calling
* [func`tld_get_base_domain]` on <literal>"co.uk"</literal>.
*/
NOT_ENOUGH_DOMAINS,
/**
* The passed-in hostname has
* no recognized public suffix.
*/
NO_BASE_DOMAIN,
/**
* The Public Suffix List was not
* available.
*/
NO_PSL_DATA,
}
/**
* Enum values passed to [func`uri_copy]` to indicate the components of
* the URI that should be updated with the given values.
*/
enum URIComponent {
/**
* no component
*/
NONE,
/**
* the URI scheme component
*/
SCHEME,
/**
* the URI user component
*/
USER,
/**
* the URI password component
*/
PASSWORD,
/**
* the URI authentication parameters component
*/
AUTH_PARAMS,
/**
* the URI host component
*/
HOST,
/**
* the URI port component
*/
PORT,
/**
* the URI path component
*/
PATH,
/**
* the URI query component
*/
QUERY,
/**
* the URI fragment component
*/
FRAGMENT,
}
/**
* Pre-defined close codes that can be passed to
* [method`WebsocketConnection`.close] or received from
* [method`WebsocketConnection`.get_close_code].
*
* However, other codes are also allowed.
*/
enum WebsocketCloseCode {
/**
* a normal, non-error close
*/
NORMAL,
/**
* the client/server is going away
*/
GOING_AWAY,
/**
* a protocol error occurred
*/
PROTOCOL_ERROR,
/**
* the endpoint received data
* of a type that it does not support.
*/
UNSUPPORTED_DATA,
/**
* reserved value indicating that
* no close code was present; must not be sent.
*/
NO_STATUS,
/**
* reserved value indicating that
* the connection was closed abnormally; must not be sent.
*/
ABNORMAL,
/**
* the endpoint received data that
* was invalid (eg, non-UTF-8 data in a text message).
*/
BAD_DATA,
/**
* generic error code
* indicating some sort of policy violation.
*/
POLICY_VIOLATION,
/**
* the endpoint received a message
* that is too big to process.
*/
TOO_BIG,
/**
* the client is closing the
* connection because the server failed to negotiate a required
* extension.
*/
NO_EXTENSION,
/**
* the server is closing the
* connection because it was unable to fulfill the request.
*/
SERVER_ERROR,
/**
* reserved value indicating that
* the TLS handshake failed; must not be sent.
*/
TLS_HANDSHAKE,
}
/**
* The type of a [class`WebsocketConnection]`.
*/
enum WebsocketConnectionType {
/**
* unknown/invalid connection
*/
UNKNOWN,
/**
* a client-side connection
*/
CLIENT,
/**
* a server-side connection
*/
SERVER,
}
/**
* The type of data contained in a [signal`WebsocketConnection:`:message] signal.
*/
enum WebsocketDataType {
/**
* UTF-8 text
*/
TEXT,
/**
* binary data
*/
BINARY,
}
/**
* WebSocket-related errors.
*/
enum WebsocketError {
/**
* a generic error
*/
FAILED,
/**
* attempted to handshake with a
* server that does not appear to understand WebSockets.
*/
NOT_WEBSOCKET,
/**
* the WebSocket handshake failed
* because some detail was invalid (eg, incorrect accept key).
*/
BAD_HANDSHAKE,
/**
* the WebSocket handshake failed
* because the "Origin" header was not an allowed value.
*/
BAD_ORIGIN,
}
/**
* The state of the WebSocket connection.
*/
enum WebsocketState {
/**
* the connection is ready to send messages
*/
OPEN,
/**
* the connection is in the process of
* closing down; messages may be received, but not sent
*/
CLOSING,
/**
* the connection is completely closed down
*/
CLOSED,
}
/**
* Indicates if a message should or shouldn't be cached.
* @bitfield
*/
enum Cacheability {
/**
* The message should be cached
*/
CACHEABLE,
/**
* The message shouldn't be cached
*/
UNCACHEABLE,
/**
* The messages cache should be invalidated
*/
INVALIDATES,
/**
* The messages cache should be updated
*/
VALIDATES,
}
/**
* Represents the parsed value of the "Expect" header.
* @bitfield
*/
enum Expectation {
/**
* any unrecognized expectation
*/
UNRECOGNIZED,
/**
* "100-continue"
*/
CONTINUE,
}
/**
* Various flags that can be set on a #SoupMessage to alter its
* behavior.
* @bitfield
*/
enum MessageFlags {
/**
* The session should not follow redirect
* (3xx) responses received by this message.
*/
NO_REDIRECT,
/**
* Requests that the message should be
* sent on a newly-created connection, not reusing an existing
* persistent connection. Note that messages with non-idempotent
* [property`Message:`method]s behave this way by default, unless
* #SOUP_MESSAGE_IDEMPOTENT is set.
*/
NEW_CONNECTION,
/**
* The message is considered idempotent,
* regardless its [property`Message:`method], and allows reuse of existing
* idle connections, instead of always requiring a new one, unless
* #SOUP_MESSAGE_NEW_CONNECTION is set.
*/
IDEMPOTENT,
/**
* The [class`AuthManager]` should not use
* the credentials cache for this message, neither to use cached credentials
* to automatically authenticate this message nor to cache the credentials
* after the message is successfully authenticated. This applies to both server
* and proxy authentication. Note that [signal`Message:`:authenticate] signal will
* be emitted, if you want to disable authentication for a message use
* [method`Message`.disable_feature] passing #SOUP_TYPE_AUTH_MANAGER instead.
*/
DO_NOT_USE_AUTH_CACHE,
/**
* Metrics will be collected for this message.
*/
COLLECT_METRICS,
}
/**
* Options to pass to [method`Server`.listen], etc.
*
* %SOUP_SERVER_LISTEN_IPV4_ONLY and %SOUP_SERVER_LISTEN_IPV6_ONLY
* only make sense with [method`Server`.listen_all] and
* [method`Server`.listen_local], not plain [method`Server`.listen] (which
* simply listens on whatever kind of socket you give it). And you
* cannot specify both of them in a single call.
* @bitfield
*/
enum ServerListenOptions {
/**
* Listen for https connections rather
* than plain http.
*/
HTTPS,
/**
* Only listen on IPv4 interfaces.
*/
IPV4_ONLY,
/**
* Only listen on IPv6 interfaces.
*/
IPV6_ONLY,
}
/**
* A constant corresponding to 1 day.
*
* For use with [ctor`Cookie`.new] and [method`Cookie`.set_max_age].
*/
const COOKIE_MAX_AGE_ONE_DAY: number;
/**
* A constant corresponding to 1 hour.
*
* For use with [ctor`Cookie`.new] and [method`Cookie`.set_max_age].
*/
const COOKIE_MAX_AGE_ONE_HOUR: number;
/**
* A constant corresponding to 1 week.
*
* For use with [ctor`Cookie`.new] and [method`Cookie`.set_max_age].
*/
const COOKIE_MAX_AGE_ONE_WEEK: number;
/**
* A constant corresponding to 1 year.
*
* For use with [ctor`Cookie`.new] and [method`Cookie`.set_max_age].
*/
const COOKIE_MAX_AGE_ONE_YEAR: number;
/**
* A macro containing the value
* `multipart/form-data`; the MIME type used for
* posting form data that contains files to be uploaded.
*/
const FORM_MIME_TYPE_MULTIPART: string | null;
/**
* A macro containing the value
* `application/x-www-form-urlencoded`; the default
* MIME type for POSTing HTML form data.
*/
const FORM_MIME_TYPE_URLENCODED: string | null;
/**
* An expiration date that is always in the past.
*/
const HSTS_POLICY_MAX_AGE_PAST: number;
/**
* The set of #GUriFlags libsoup expects all #GUri to use.
*/
const HTTP_URI_FLAGS: number;
/**
* Like [func`get_major_version]`, but from the headers used at application
* compile time, rather than from the library linked against at application run
* time.
*/
const MAJOR_VERSION: number;
/**
* Like [func`get_micro_version]`, but from the headers used at
* application compile time, rather than from the library linked
* against at application run time.
*/
const MICRO_VERSION: number;
/**
* Like [func`get_minor_version]`, but from the headers used at
* application compile time, rather than from the library linked
* against at application run time.
*/
const MINOR_VERSION: number;
/**
* A macro that should be defined by the user prior to including
* `libsoup.h`.
*
* The definition should be one of the predefined libsoup
* version macros: %SOUP_VERSION_2_24, %SOUP_VERSION_2_26, ...
*
* This macro defines the earliest version of libsoup that the package
* is required to be able to compile against.
*
* If the compiler is configured to warn about the use of deprecated
* functions, then using functions that were deprecated in version
* %SOUP_VERSION_MIN_REQUIRED or earlier will cause warnings (but
* using functions deprecated in later releases will not).
*/
const VERSION_MIN_REQUIRED: number;
/**
* Like [func`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.
* @param major the major version to check
* @param minor the minor version to check
* @param micro the micro version to check
* @returns %TRUE if the version of the libsoup currently loaded is the same as or newer than the passed-in version.
*/
function check_version(major: number, minor: number, micro: number): boolean;
/**
* Parses `header` and returns a #SoupCookie.
*
* 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 %NULL, path will default
* to "/", but domain will be left as %NULL. Note that this is not a
* valid state for a #SoupCookie, 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 %SOUP_SAME_SITE_POLICY_LAX.
* @param header a cookie string (eg, the value of a Set-Cookie header)
* @param origin origin of the cookie
* @returns a new #SoupCookie, or %NULL if it could not be parsed, or contained an illegal "domain" attribute for a cookie originating from @origin.
*/
function cookie_parse(
header: string | null,
origin: GLib.Uri | null
): Cookie | null;
/**
* Parses `msg'`s Cookie request header and returns a [struct`GLib`.SList] of
* `SoupCookie`s.
*
* As the "Cookie" header, unlike "Set-Cookie", only contains cookie names and
* values, none of the other #SoupCookie fields will be filled in. (Thus, you
* can't generally pass a cookie returned from this method directly to
* [func`cookies_to_response]`.)
* @param msg a #SoupMessage containing a "Cookie" request header
* @returns a #GSList of `SoupCookie`s, which can be freed with [method@Cookie.free].
*/
function cookies_from_request(msg: Message): Cookie[];
/**
* Parses `msg'`s Set-Cookie response headers and returns a [struct`GLib`.SList]
* of `SoupCookie`s.
*
* Cookies that do not specify "path" or "domain" attributes will have their
* values defaulted from `msg`.
* @param msg a #SoupMessage containing a "Set-Cookie" response header
* @returns a #GSList of `SoupCookie`s, which can be freed with [method@Cookie.free].
*/
function cookies_from_response(msg: Message): Cookie[];
/**
* Serializes a [struct`GLib`.SList] of #SoupCookie into a string suitable for
* setting as the value of the "Cookie" header.
* @param cookies a #GSList of #SoupCookie
* @returns the serialization of @cookies
*/
function cookies_to_cookie_header(cookies: Cookie[]): string | null;
/**
* 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.
* @param cookies a #GSList of #SoupCookie
* @param msg a #SoupMessage
*/
function cookies_to_request(cookies: Cookie[], msg: Message): void;
/**
* 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.
* @param cookies a #GSList of #SoupCookie
* @param msg a #SoupMessage
*/
function cookies_to_response(cookies: Cookie[], msg: Message): void;
/**
* 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.)
* @param date_string The date as a string
* @returns a new #GDateTime, or %NULL if @date_string could not be parsed.
*/
function date_time_new_from_http_string(
date_string: string | null
): GLib.DateTime | null;
/**
* Converts `date` to a string in the format described by `format`.
* @param date a #GDateTime
* @param format the format to generate the date in
* @returns @date as a string or %NULL
*/
function date_time_to_string(
date: GLib.DateTime,
format: DateFormat
): string | null;
/**
* Decodes `form`.
*
* which is an urlencoded dataset as defined in the HTML 4.01 spec.
* @param encoded_form data of type "application/x-www-form-urlencoded"
* @returns a hash table containing the name/value pairs from @encoded_form, which you can free with [func@GLib.HashTable.destroy].
*/
function form_decode(encoded_form: string | null): GLib.HashTable;
/**
* 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 [func`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
* [func`form_decode]` in the returned [struct`GLib`.HashTable].
*
* You may pass %NULL for `filename,` `content_type` and/or `file` if you do not
* care about those fields. [func`form_decode_multipart]` may also
* return %NULL in those fields if the client did not provide that
* information. You must free the returned filename and content-type
* with [func`GLib`.free], and the returned file data with [method`Glib`.Bytes.unref].
*
* If you have a form with more than one file upload control, you will
* need to decode it manually, using [ctor`Multipart`.new_from_message]
* and [method`Multipart`.get_part].
* @param multipart a #SoupMultipart
* @param file_control_name the name of the HTML file upload control
* @returns a hash table containing the name/value pairs (other than @file_control_name) from @msg, which you can free with [func@GLib.HashTable.destroy]. On error, it will return %NULL.
*/
function form_decode_multipart(
multipart: Multipart,
file_control_name: string | null
): [
/* returnType */ GLib.HashTable | null,
/* filename */ string | null,
/* content_type */ string | null,
/* file */ GLib.Bytes
];
/**
* Encodes `form_data_set` into a value of type
* "application/x-www-form-urlencoded".
*
* Encodes as defined in the HTML 4.01 spec. Unlike [func`form_encode_hash]`,
* this preserves the ordering of the form elements, which may be required in
* some situations.
*
* See also: [ctor`Message`.new_from_encoded_form].
* @param form_data_set a datalist containing name/value pairs
* @returns the encoded form
*/
function form_encode_datalist(form_data_set: GLib.Data): string | null;
/**
* 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 [func`form_encode_datalist]`.
*
* See also: [ctor`Message`.new_from_encoded_form].
* @param form_data_set a hash table containing name/value pairs (as strings)
* @returns the encoded form
*/
function form_encode_hash(form_data_set: GLib.HashTable): string | null;
/**
* 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.
* @returns the major version number of the libsoup library
*/
function get_major_version(): number;
/**
* 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.
* @returns the micro version number of the libsoup library
*/
function get_micro_version(): number;
/**
* 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.
* @returns the minor version number of the libsoup library
*/
function get_minor_version(): number;
/**
* 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.
* @param header An HTTP header suitable for parsing with [func`header_parse_list]`
* @param token a token
* @returns whether or not @header contains @token
*/
function header_contains(
header: string | null,
token: string | null
): boolean;
/**
* Frees `param_list`.
* @param param_list a #GHashTable returned from [func`header_parse_param_list]` or [func`header_parse_semi_param_list]`
*/
function header_free_param_list(param_list: GLib.HashTable): void;
/**
* 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 %NULL, this will just append `name` to `string`.
* @param string a #GString being used to construct an HTTP header value
* @param name a parameter name
* @param value a parameter value, or %NULL
*/
function header_g_string_append_param(
string: GLib.String,
name: string | null,
value: string | null
): void;
/**
* 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 [func`header_g_string_append_param]`.
* @param string a #GString being used to construct an HTTP header value
* @param name a parameter name
* @param value a parameter value
*/
function header_g_string_append_param_quoted(
string: GLib.String,
name: string | null,
value: string | null
): void;
/**
* Parses a header whose content is described by RFC2616 as `#something`.
*
* "something" does not itself contain commas, except as part of quoted-strings.
* @param header a header value
* @returns a #GSList of list elements, as allocated strings
*/
function header_parse_list(header: string | null): string[];
/**
* 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 %NULL value.
*
* This also handles RFC5987 encoding (which in HTTP is mostly used
* for giving UTF8-encoded filenames in the Content-Disposition
* header).
* @param header a header value
* @returns a #GHashTable of list elements, which can be freed with [func@header_free_param_list].
*/
function header_parse_param_list(header: string | null): GLib.HashTable;
/**
* A strict version of [func`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
* [func`header_parse_param_list]` instead.
* @param header a header value
* @returns a #GHashTable of list elements, which can be freed with [func@header_free_param_list] or %NULL if there are duplicate elements.
*/
function header_parse_param_list_strict(
header: string | null
): GLib.HashTable | null;
/**
* 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 %NULL, then on return, it will contain the
* items with qvalue 0. Either way, those items will be removed from
* the main list.
* @param header a header value
* @returns a #GSList of acceptable values (as allocated strings), highest-qvalue first.
*/
function header_parse_quality_list(
header: string | null
): [/* returnType */ string[], /* unacceptable */ string[]];
/**
* 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 %NULL value.
*
* This also handles RFC5987 encoding (which in HTTP is mostly used
* for giving UTF8-encoded filenames in the Content-Disposition
* header).
* @param header a header value
* @returns a #GHashTable of list elements, which can be freed with [func@header_free_param_list].
*/
function header_parse_semi_param_list(header: string | null): GLib.HashTable;
/**
* A strict version of [func`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
* [func`header_parse_semi_param_list]` instead.
* @param header a header value
* @returns a #GHashTable of list elements, which can be freed with [func@header_free_param_list] or %NULL if there are duplicate elements.
*/
function header_parse_semi_param_list_strict(
header: string | null
): GLib.HashTable | null;
/**
* 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
* [func`headers_parse_request]` or [func`headers_parse_response]`.
* @param str the header string (including the Request-Line or Status-Line, but not the trailing blank line)
* @param len length of `str`
* @param dest #SoupMessageHeaders to store the header values in
* @returns success or failure
*/
function headers_parse(
str: string | null,
len: number,
dest: MessageHeaders
): boolean;
/**
* 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.
* @param str the headers (up to, but not including, the trailing blank line)
* @param len length of `str`
* @param req_headers #SoupMessageHeaders to store the header values in
* @returns %SOUP_STATUS_OK if the headers could be parsed, or an HTTP error to be returned to the client if they could not be.
*/
function headers_parse_request(
str: string | null,
len: number,
req_headers: MessageHeaders
): [
/* returnType */ number,
/* req_method */ string | null,
/* req_path */ string | null,
/* ver */ HTTPVersion
];
/**
* 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.
* @param str the headers (up to, but not including, the trailing blank line)
* @param len length of `str`
* @param headers #SoupMessageHeaders to store the header values in
* @returns success or failure.
*/
function headers_parse_response(
str: string | null,
len: number,
headers: MessageHeaders
): [
/* returnType */ boolean,
/* ver */ HTTPVersion,
/* status_code */ number,
/* reason_phrase */ string | null
];
/**
* 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".
* @param status_line an HTTP Status-Line
* @returns %TRUE if @status_line was parsed successfully.
*/
function headers_parse_status_line(
status_line: string | null
): [
/* returnType */ boolean,
/* ver */ HTTPVersion,
/* status_code */ number,
/* reason_phrase */ string | null
];
/**
* Initializes `iter` for iterating `hdrs`.
* @param hdrs a %SoupMessageHeaders
*/
function message_headers_iter_init(
hdrs: MessageHeaders
): /* iter */ MessageHeadersIter;
/**
* Registers error quark for SoupSession if needed.
* @returns Error quark for SoupSession.
*/
function session_error_quark(): GLib.Quark;
/**
* 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
* [property`Message:`status-code] of a given [class`Message]`, you should just
* look at the message's [property`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.
* @param status_code an HTTP status code
* @returns the (terse, English) description of @status_code
*/
function status_get_phrase(status_code: number): string | null;
/**
* 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.
* @param domain a domain name
* @returns %TRUE if it is a public domain, %FALSE otherwise.
*/
function tld_domain_is_public_suffix(domain: string | null): boolean;
/**
* Registers error quark for soup_tld_get_base_domain() if needed.
* @returns Error quark for Soup TLD functions.
*/
function tld_error_quark(): GLib.Quark;
/**
* 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 %NULL 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).
* @param hostname a hostname
* @returns a pointer to the start of the base domain in @hostname. If an error occurs, %NULL will be returned and @error set.
*/
function tld_get_base_domain(hostname: string | null): string | null;
/**
* Decodes the given data URI and returns its contents and `content_type`.
* @param uri a data URI, in string form
* @returns a #GBytes with the contents of @uri, or %NULL if @uri is not a valid data URI
*/
function uri_decode_data_uri(
uri: string | null
): [/* returnType */ GLib.Bytes, /* content_type */ string | null];
/**
* Tests whether or not `uri1` and `uri2` are equal in all parts.
* @param uri1 a #GUri
* @param uri2 another #GUri
* @returns %TRUE if equal otherwise %FALSE
*/
function uri_equal(uri1: GLib.Uri, uri2: GLib.Uri): boolean;
/**
* Adds the necessary headers to `msg` to request a WebSocket
* handshake including supported WebSocket extensions.
*
* The message body and non-WebSocket-related headers are
* not modified.
*
* This is a low-level function; if you use
* [method`Session`.websocket_connect_async] to create a WebSocket connection, it
* will call this for you.
* @param msg a #SoupMessage
* @param origin the "Origin" header to set
* @param protocols list of protocols to offer
* @param supported_extensions list of supported extension types
*/
function websocket_client_prepare_handshake(
msg: Message,
origin: string | null,
protocols: string[] | null,
supported_extensions: GObject.TypeClass[] | null
): void;
/**
* Looks at the response status code and headers in `msg` and
* determines if they contain a valid WebSocket handshake response
* (given the handshake request in `msg'`s request headers).
*
* If `supported_extensions` is non-%NULL, extensions included in the
* response "Sec-WebSocket-Extensions" are verified too. Accepted
* extensions are returned in `accepted_extensions` parameter if non-%NULL.
*
* This is a low-level function; if you use
* [method`Session`.websocket_connect_async] to create a WebSocket
* connection, it will call this for you.
* @param msg #SoupMessage containing both client and server sides of a WebSocket handshake
* @param supported_extensions list of supported extension types
* @returns %TRUE if @msg contains a completed valid WebSocket handshake, %FALSE and an error if not.
*/
function websocket_client_verify_handshake(
msg: Message,
supported_extensions: GObject.TypeClass[] | null
): [/* returnType */ boolean, /* accepted_extensions */ WebsocketExtension[]];
/**
* Registers error quark for SoupWebsocket if needed.
* @returns Error quark for SoupWebsocket.
*/
function websocket_error_quark(): GLib.Quark;
/**
* Examines the method and request headers in `msg` and determines
* whether `msg` contains a valid handshake request.
*
* If `origin` is non-%NULL, then only requests containing a matching
* "Origin" header will be accepted. If `protocols` is non-%NULL, then
* only requests containing a compatible "Sec-WebSocket-Protocols"
* header will be accepted. If `supported_extensions` is non-%NULL, then
* only requests containing valid supported extensions in
* "Sec-WebSocket-Extensions" header will be accepted.
*
* Normally [func`websocket_server_process_handshake]`
* will take care of this for you, and if you use
* [method`Server`.add_websocket_handler] to handle accepting WebSocket
* connections, it will call that for you. However, this function may
* be useful if you need to perform more complicated validation; eg,
* accepting multiple different Origins, or handling different protocols
* depending on the path.
* @param msg #SoupServerMessage containing the client side of a WebSocket handshake
* @param origin expected Origin header
* @param protocols allowed WebSocket protocols.
* @param supported_extensions list of supported extension types
* @returns %TRUE if @msg contained a valid WebSocket handshake, %FALSE and an error if not.
*/
function websocket_server_check_handshake(
msg: ServerMessage,
origin: string | null,
protocols: string[] | null,
supported_extensions: GObject.TypeClass[] | null
): boolean;
/**
* Examines the method and request headers in `msg` and (assuming `msg`
* contains a valid handshake request), fills in the handshake
* response.
*
* If `expected_origin` is non-%NULL, then only requests containing a matching
* "Origin" header will be accepted. If `protocols` is non-%NULL, then
* only requests containing a compatible "Sec-WebSocket-Protocols"
* header will be accepted. If `supported_extensions` is non-%NULL, then
* only requests containing valid supported extensions in
* "Sec-WebSocket-Extensions" header will be accepted. The accepted extensions
* will be returned in `accepted_extensions` parameter if non-%NULL.
*
* This is a low-level function; if you use
* [method`Server`.add_websocket_handler] to handle accepting WebSocket
* connections, it will call this for you.
* @param msg #SoupServerMessage containing the client side of a WebSocket handshake
* @param expected_origin expected Origin header
* @param protocols allowed WebSocket protocols.
* @param supported_extensions list of supported extension types
* @returns %TRUE if @msg contained a valid WebSocket handshake request and was updated to contain a handshake response. %FALSE if not.
*/
function websocket_server_process_handshake(
msg: ServerMessage,
expected_origin: string | null,
protocols: string[] | null,
supported_extensions: GObject.TypeClass[] | null
): [/* returnType */ boolean, /* accepted_extensions */ WebsocketExtension[]];
/**
* Callback used by #SoupAuthDomainBasic for authentication purposes.
*
* The application should verify that `username` and `password` and valid
* and return %TRUE or %FALSE.
*
* If you are maintaining your own password database (rather than
* using the password to authenticate against some other system like
* PAM or a remote server), you should make sure you know what you are
* doing. In particular, don't store cleartext passwords, or
* easily-computed hashes of cleartext passwords, even if you don't
* care that much about the security of your server, because users
* will frequently use the same password for multiple sites, and so
* compromising any site with a cleartext (or easily-cracked) password
* database may give attackers access to other more-interesting sites
* as well.
* @callback
* @param domain the domain
* @param msg the message being authenticated
* @param username the username provided by the client
* @param password the password provided by the client
* @returns %TRUE if @username and @password are valid
*/
interface AuthDomainBasicAuthCallback {
(
domain: AuthDomainBasic,
msg: ServerMessage,
username: string | null,
password: string | null
): boolean;
}
/**
* Callback used by #SoupAuthDomainDigest for authentication purposes.
*
* The application should look up `username` in its password database,
* and return the corresponding encoded password (see
* [func`AuthDomainDigest`.encode_password].
* @callback
* @param domain the domain
* @param msg the message being authenticated
* @param username the username provided by the client
* @returns the encoded password, or %NULL if @username is not a valid user. @domain will free the password when it is done with it.
*/
interface