Gjsify LogoGjsify Logo

Index

Enumerations

Classes

Interfaces

Variables

Functions

Variables

COOKIE_MAX_AGE_ONE_DAY: number

A constant corresponding to 1 day, for use with soup_cookie_new() and soup_cookie_set_max_age().

COOKIE_MAX_AGE_ONE_HOUR: number

A constant corresponding to 1 hour, for use with soup_cookie_new() and soup_cookie_set_max_age().

COOKIE_MAX_AGE_ONE_WEEK: number

A constant corresponding to 1 week, for use with soup_cookie_new() and soup_cookie_set_max_age().

COOKIE_MAX_AGE_ONE_YEAR: number

A constant corresponding to 1 year, for use with soup_cookie_new() and soup_cookie_set_max_age().

FORM_MIME_TYPE_MULTIPART: string

A macro containing the value "multipart/form-data"; the MIME type used for posting form data that contains files to be uploaded.

FORM_MIME_TYPE_URLENCODED: string

A macro containing the value "application/x-www-form-urlencoded"; the default MIME type for POSTing HTML form data.

HSTS_POLICY_MAX_AGE_PAST: number

An expiration date that is always in the past.

HTTP_URI_FLAGS: number

The set of #GUriFlags libsoup expects all #GUri to use.

MAJOR_VERSION: number

Like soup_get_major_version(), but from the headers used at application compile time, rather than from the library linked against at application run time.

MICRO_VERSION: number

Like soup_get_micro_version(), but from the headers used at application compile time, rather than from the library linked against at application run time.

MINOR_VERSION: number

Like soup_get_minor_version(), but from the headers used at application compile time, rather than from the library linked against at application run time.

VERSION_MIN_REQUIRED: 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).

Functions

  • check_version(major: number, minor: number, micro: number): boolean
  • Like SOUP_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.

    Parameters

    • major: number

      the major version to check

    • minor: number

      the minor version to check

    • micro: number

      the micro version to check

    Returns 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.

    Parameters

    • header: string

      a cookie string (eg, the value of a Set-Cookie header)

    • origin: GLib.Uri

      origin of the cookie, or %NULL

    Returns Soup.Cookie | null

  • Parses msg's Cookie request header and returns a #GSList of #SoupCookies. 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 soup_cookies_to_response().)

    Parameters

    • msg: Soup.Message

      a #SoupMessage containing a "Cookie" request header

    Returns Soup.Cookie[]

  • Parses msg's Set-Cookie response headers and returns a #GSList of #SoupCookies. Cookies that do not specify "path" or "domain" attributes will have their values defaulted from msg.

    Parameters

    • msg: Soup.Message

      a #SoupMessage containing a "Set-Cookie" response header

    Returns Soup.Cookie[]

  • cookies_to_cookie_header(cookies: Soup.Cookie[]): string
  • Serializes a #GSList of #SoupCookie into a string suitable for setting as the value of the "Cookie" header.

    Parameters

    Returns string

  • 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.)

    Parameters

    Returns 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.)

    Parameters

    Returns void

  • date_time_new_from_http_string(date_string: string): GLib.DateTime | null
  • 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.)

    Parameters

    • date_string: string

      The date as a string

    Returns GLib.DateTime | null

  • Decodes form, which is an urlencoded dataset as defined in the HTML 4.01 spec.

    Parameters

    • encoded_form: string

      data of type "application/x-www-form-urlencoded"

    Returns 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 soup_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 soup_form_decode()) in the returned #GHashTable.

    You may pass %NULL for filename, content_type and/or file if you do not care about those fields. soup_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 g_free(), and the returned file data with g_bytes_unref().

    If you have a form with more than one file upload control, you will need to decode it manually, using soup_multipart_new_from_message() and soup_multipart_get_part().

    Parameters

    • multipart: Soup.Multipart

      a #SoupMultipart

    • file_control_name: string

      the name of the HTML file upload control, or %NULL

    Returns [HashTable | null, string, string, Bytes]

  • form_encode_datalist(form_data_set: GLib.Data): string
  • Encodes form_data_set into a value of type "application/x-www-form-urlencoded", as defined in the HTML 4.01 spec. Unlike soup_form_encode_hash(), this preserves the ordering of the form elements, which may be required in some situations.

    Parameters

    • form_data_set: GLib.Data

      a datalist containing name/value pairs

    Returns string

  • form_encode_hash(form_data_set: HashTable<string | number | symbol, string | number | boolean>): string
  • Encodes form_data_set into a value of type "application/x-www-form-urlencoded", 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 soup_form_encode_datalist().

    Parameters

    • form_data_set: HashTable<string | number | symbol, string | number | boolean>

      a hash table containing name/value pairs (as strings)

    Returns string

  • get_major_version(): number
  • 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 number

  • get_micro_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 number

  • get_minor_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 number

  • header_contains(header: string, token: string): boolean
  • 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.

    Parameters

    • header: string

      An HTTP header suitable for parsing with soup_header_parse_list()

    • token: string

      a token

    Returns boolean

  • header_free_param_list(param_list: HashTable<string | number | symbol, string | number | boolean>): void
  • Frees param_list.

    Parameters

    • param_list: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable returned from soup_header_parse_param_list() or soup_header_parse_semi_param_list()

    Returns void

  • header_g_string_append_param(string: GLib.String, name: string, value: string): void
  • Appends something like name=``value</literal> 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.

    Parameters

    • string: GLib.String

      a #GString being used to construct an HTTP header value

    • name: string

      a parameter name

    • value: string

      a parameter value, or %NULL

    Returns void

  • header_g_string_append_param_quoted(string: GLib.String, name: string, value: string): 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 soup_header_g_string_append_param().

    Parameters

    • string: GLib.String

      a #GString being used to construct an HTTP header value

    • name: string

      a parameter name

    • value: string

      a parameter value

    Returns void

  • header_parse_list(header: string): string[]
  • Parses a header whose content is described by RFC2616 as "#something", where "something" does not itself contain commas, except as part of quoted-strings.

    Parameters

    • header: string

      a header value

    Returns string[]

  • header_parse_param_list(header: string): HashTable
  • 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).

    Parameters

    • header: string

      a header value

    Returns HashTable

  • header_parse_param_list_strict(header: string): HashTable | null
  • A strict version of soup_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 soup_header_parse_param_list() instead.

    Parameters

    • header: string

      a header value

    Returns HashTable | null

  • header_parse_quality_list(header: string): [string[], string[]]
  • 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.

    Parameters

    • header: string

      a header value

    Returns [string[], string[]]

  • header_parse_semi_param_list(header: string): HashTable
  • 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).

    Parameters

    • header: string

      a header value

    Returns HashTable

  • header_parse_semi_param_list_strict(header: string): HashTable | null
  • A strict version of soup_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 soup_header_parse_semi_param_list() instead.

    Parameters

    • header: string

      a header value

    Returns 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 soup_headers_parse_request() or soup_headers_parse_response().

    Parameters

    • str: string

      the header string (including the Request-Line or Status-Line, but not the trailing blank line)

    • len: number

      length of str

    • dest: Soup.MessageHeaders

      #SoupMessageHeaders to store the header values in

    Returns 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.

    Parameters

    • str: string

      the headers (up to, but not including, the trailing blank line)

    • len: number

      length of str

    • req_headers: Soup.MessageHeaders

      #SoupMessageHeaders to store the header values in

    Returns [number, string, string, Soup.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.

    Parameters

    • str: string

      the headers (up to, but not including, the trailing blank line)

    • len: number

      length of str

    • headers: Soup.MessageHeaders

      #SoupMessageHeaders to store the header values in

    Returns [boolean, Soup.HTTPVersion, number, string]

  • headers_parse_status_line(status_line: string): [boolean, Soup.HTTPVersion, number, string]
  • 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".

    Parameters

    • status_line: string

      an HTTP Status-Line

    Returns [boolean, Soup.HTTPVersion, number, string]

  • session_error_quark(): Quark
  • status_get_phrase(status_code: number): string
  • 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 #SoupMessage:status_code of a given #SoupMessage, you should just look at the message's #SoupMessage: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.

    Parameters

    • status_code: number

      an HTTP status code

    Returns string

  • tld_domain_is_public_suffix(domain: string): boolean
  • 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.

    Parameters

    • domain: string

      a domain name

    Returns boolean

  • tld_get_base_domain(hostname: string): string
  • 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).

    Parameters

    • hostname: string

      a hostname

    Returns string

  • uri_decode_data_uri(uri: string): [Bytes, string | null]
  • Decodes the given data URI and returns its contents and content_type.

    Parameters

    • uri: string

      a data URI, in string form

    Returns [Bytes, string | null]

  • websocket_client_prepare_handshake(msg: Soup.Message, origin: string, protocols: string[], supported_extensions: GObject.TypeClass[]): void
  • 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 soup_session_websocket_connect_async() to create a WebSocket connection, it will call this for you.

    Parameters

    • msg: Soup.Message

      a #SoupMessage

    • origin: string

      the "Origin" header to set

    • protocols: string[]

      list of protocols to offer

    • supported_extensions: GObject.TypeClass[]

      list of supported extension types

    Returns 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 soup_session_websocket_connect_async() to create a WebSocket connection, it will call this for you.

    Parameters

    • msg: Soup.Message

      #SoupMessage containing both client and server sides of a WebSocket handshake

    • supported_extensions: GObject.TypeClass[]

      list of supported extension types

    Returns [boolean, Soup.WebsocketExtension[]]

  • websocket_error_quark(): 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 soup_websocket_server_process_handshake() will take care of this for you, and if you use soup_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.

    Parameters

    • msg: ServerMessage

      #SoupServerMessage containing the client side of a WebSocket handshake

    • origin: string

      expected Origin header

    • protocols: string[]

      allowed WebSocket protocols.

    • supported_extensions: GObject.TypeClass[]

      list of supported extension types

    Returns 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 soup_server_add_websocket_handler() to handle accepting WebSocket connections, it will call this for you.

    Parameters

    • msg: ServerMessage

      #SoupServerMessage containing the client side of a WebSocket handshake

    • expected_origin: string

      expected Origin header

    • protocols: string[]

      allowed WebSocket protocols.

    • supported_extensions: GObject.TypeClass[]

      list of supported extension types

    Returns [boolean, Soup.WebsocketExtension[]]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method