soup

package
v0.0.0-...-dee1973 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const COOKIE_MAX_AGE_ONE_DAY = 0

COOKIE_MAX_AGE_ONE_DAY: constant corresponding to 1 day.

For use with cookie.New and cookie.SetMaxAge.

View Source
const COOKIE_MAX_AGE_ONE_HOUR = 3600

COOKIE_MAX_AGE_ONE_HOUR: constant corresponding to 1 hour.

For use with cookie.New and cookie.SetMaxAge.

View Source
const COOKIE_MAX_AGE_ONE_WEEK = 0

COOKIE_MAX_AGE_ONE_WEEK: constant corresponding to 1 week.

For use with cookie.New and cookie.SetMaxAge.

View Source
const COOKIE_MAX_AGE_ONE_YEAR = 0

COOKIE_MAX_AGE_ONE_YEAR: constant corresponding to 1 year.

For use with cookie.New and cookie.SetMaxAge.

View Source
const FORM_MIME_TYPE_MULTIPART = "multipart/form-data"

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

View Source
const FORM_MIME_TYPE_URLENCODED = "application/x-www-form-urlencoded"

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

View Source
const HSTS_POLICY_MAX_AGE_PAST = 0

HSTS_POLICY_MAX_AGE_PAST: expiration date that is always in the past.

View Source
const HTTP_URI_FLAGS = 482

HTTP_URI_FLAGS: set of Flags libsoup expects all #GUri to use.

View Source
const MAJOR_VERSION = 3

MAJOR_VERSION: like get_major_version, but from the headers used at application compile time, rather than from the library linked against at application run time.

View Source
const MICRO_VERSION = 4

MICRO_VERSION: like get_micro_version, but from the headers used at application compile time, rather than from the library linked against at application run time.

View Source
const MINOR_VERSION = 4

MINOR_VERSION: like get_minor_version, but from the headers used at application compile time, rather than from the library linked against at application run time.

View Source
const VERSION_MIN_REQUIRED = 2

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

Variables

View Source
var (
	GTypeCacheType    = coreglib.Type(C.soup_cache_type_get_type())
	GTypeCacheability = coreglib.Type(C.soup_cacheability_get_type())
	GTypeCache        = coreglib.Type(C.soup_cache_get_type())
)

GType values.

View Source
var (
	GTypeCookieJarAcceptPolicy = coreglib.Type(C.soup_cookie_jar_accept_policy_get_type())
	GTypeCookieJar             = coreglib.Type(C.soup_cookie_jar_get_type())
)

GType values.

View Source
var (
	GTypeLoggerLogLevel = coreglib.Type(C.soup_logger_log_level_get_type())
	GTypeLogger         = coreglib.Type(C.soup_logger_get_type())
)

GType values.

View Source
var (
	GTypeMemoryUse   = coreglib.Type(C.soup_memory_use_get_type())
	GTypeMessageBody = coreglib.Type(C.soup_message_body_get_type())
)

GType values.

View Source
var (
	GTypeEncoding           = coreglib.Type(C.soup_encoding_get_type())
	GTypeMessageHeadersType = coreglib.Type(C.soup_message_headers_type_get_type())
	GTypeExpectation        = coreglib.Type(C.soup_expectation_get_type())
	GTypeMessageHeaders     = coreglib.Type(C.soup_message_headers_get_type())
)

GType values.

View Source
var (
	GTypeMessagePriority = coreglib.Type(C.soup_message_priority_get_type())
	GTypeMessageFlags    = coreglib.Type(C.soup_message_flags_get_type())
	GTypeMessage         = coreglib.Type(C.soup_message_get_type())
)

GType values.

View Source
var (
	GTypeServerListenOptions = coreglib.Type(C.soup_server_listen_options_get_type())
	GTypeServer              = coreglib.Type(C.soup_server_get_type())
)

GType values.

View Source
var (
	GTypeSessionError = coreglib.Type(C.soup_session_error_get_type())
	GTypeSession      = coreglib.Type(C.soup_session_get_type())
)

GType values.

View Source
var (
	GTypeHTTPVersion = coreglib.Type(C.soup_http_version_get_type())
	GTypeStatus      = coreglib.Type(C.soup_status_get_type())
)

GType values.

View Source
var (
	GTypeCookie         = coreglib.Type(C.soup_cookie_get_type())
	GTypeHSTSPolicy     = coreglib.Type(C.soup_hsts_policy_get_type())
	GTypeMessageMetrics = coreglib.Type(C.soup_message_metrics_get_type())
)

GType values.

View Source
var (
	GTypeWebsocketCloseCode      = coreglib.Type(C.soup_websocket_close_code_get_type())
	GTypeWebsocketConnectionType = coreglib.Type(C.soup_websocket_connection_type_get_type())
	GTypeWebsocketDataType       = coreglib.Type(C.soup_websocket_data_type_get_type())
	GTypeWebsocketError          = coreglib.Type(C.soup_websocket_error_get_type())
	GTypeWebsocketState          = coreglib.Type(C.soup_websocket_state_get_type())
)

GType values.

View Source
var (
	GTypeAuth = coreglib.Type(C.soup_auth_get_type())
)

GType values.

View Source
var (
	GTypeAuthBasic = coreglib.Type(C.soup_auth_basic_get_type())
)

GType values.

View Source
var (
	GTypeAuthDigest = coreglib.Type(C.soup_auth_digest_get_type())
)

GType values.

View Source
var (
	GTypeAuthDomain = coreglib.Type(C.soup_auth_domain_get_type())
)

GType values.

View Source
var (
	GTypeAuthDomainBasic = coreglib.Type(C.soup_auth_domain_basic_get_type())
)

GType values.

View Source
var (
	GTypeAuthDomainDigest = coreglib.Type(C.soup_auth_domain_digest_get_type())
)

GType values.

View Source
var (
	GTypeAuthManager = coreglib.Type(C.soup_auth_manager_get_type())
)

GType values.

View Source
var (
	GTypeAuthNTLM = coreglib.Type(C.soup_auth_ntlm_get_type())
)

GType values.

View Source
var (
	GTypeAuthNegotiate = coreglib.Type(C.soup_auth_negotiate_get_type())
)

GType values.

View Source
var (
	GTypeContentDecoder = coreglib.Type(C.soup_content_decoder_get_type())
)

GType values.

View Source
var (
	GTypeContentSniffer = coreglib.Type(C.soup_content_sniffer_get_type())
)

GType values.

View Source
var (
	GTypeCookieJarDB = coreglib.Type(C.soup_cookie_jar_db_get_type())
)

GType values.

View Source
var (
	GTypeCookieJarText = coreglib.Type(C.soup_cookie_jar_text_get_type())
)

GType values.

View Source
var (
	GTypeDateFormat = coreglib.Type(C.soup_date_format_get_type())
)

GType values.

View Source
var (
	GTypeHSTSEnforcer = coreglib.Type(C.soup_hsts_enforcer_get_type())
)

GType values.

View Source
var (
	GTypeHSTSEnforcerDB = coreglib.Type(C.soup_hsts_enforcer_db_get_type())
)

GType values.

View Source
var (
	GTypeMultipart = coreglib.Type(C.soup_multipart_get_type())
)

GType values.

View Source
var (
	GTypeMultipartInputStream = coreglib.Type(C.soup_multipart_input_stream_get_type())
)

GType values.

View Source
var (
	GTypeSameSitePolicy = coreglib.Type(C.soup_same_site_policy_get_type())
)

GType values.

View Source
var (
	GTypeServerMessage = coreglib.Type(C.soup_server_message_get_type())
)

GType values.

View Source
var (
	GTypeSessionFeature = coreglib.Type(C.soup_session_feature_get_type())
)

GType values.

View Source
var (
	GTypeTLDError = coreglib.Type(C.soup_tld_error_get_type())
)

GType values.

View Source
var (
	GTypeURIComponent = coreglib.Type(C.soup_uri_component_get_type())
)

GType values.

View Source
var (
	GTypeWebsocketConnection = coreglib.Type(C.soup_websocket_connection_get_type())
)

GType values.

View Source
var (
	GTypeWebsocketExtension = coreglib.Type(C.soup_websocket_extension_get_type())
)

GType values.

View Source
var (
	GTypeWebsocketExtensionDeflate = coreglib.Type(C.soup_websocket_extension_deflate_get_type())
)

GType values.

View Source
var (
	GTypeWebsocketExtensionManager = coreglib.Type(C.soup_websocket_extension_manager_get_type())
)

GType values.

Functions

func AuthDomainDigestEncodePassword

func AuthDomainDigestEncodePassword(username, realm, password string) string

AuthDomainDigestEncodePassword encodes the username/realm/password triplet for Digest authentication.

That is, it returns a stringified MD5 hash of username, realm, and password concatenated together. This is the form that is needed as the return value of AuthDomainDigest's auth handler.

For security reasons, you should store the encoded hash, rather than storing the cleartext password itself and calling this method only when you need to verify it. This way, if your server is compromised, the attackers will not gain access to cleartext passwords which might also be usable at other sites. (Note also that the encoded password returned by this method is identical to the encoded password stored in an Apache .htdigest file.).

The function takes the following parameters:

  • username: username.
  • realm: auth realm name.
  • password for username in realm.

The function returns the following values:

  • utf8: encoded password.

func AuthNegotiateSupported

func AuthNegotiateSupported() bool

AuthNegotiateSupported indicates whether libsoup was built with GSSAPI support.

If this is FALSE, SOUP_TYPE_AUTH_NEGOTIATE will still be defined and can still be added to a session, but libsoup will never attempt to actually use this auth type.

The function returns the following values:

  • ok: TRUE if supported otherwise FALSE.

func CheckVersion

func CheckVersion(major, minor, micro uint) bool

CheckVersion: 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.

The function takes the following parameters:

  • major version to check.
  • minor version to check.
  • micro version to check.

The function returns the following values:

  • ok: TRUE if the version of the libsoup currently loaded is the same as or newer than the passed-in version.

func CookiesToCookieHeader

func CookiesToCookieHeader(cookies []*Cookie) string

CookiesToCookieHeader serializes a glib.SList of Cookie into a string suitable for setting as the value of the "Cookie" header.

The function takes the following parameters:

  • cookies of Cookie.

The function returns the following values:

  • utf8: serialization of cookies.

func CookiesToRequest

func CookiesToRequest(cookies []*Cookie, msg *Message)

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

The function takes the following parameters:

  • cookies of Cookie.
  • msg: Message.

func CookiesToResponse

func CookiesToResponse(cookies []*Cookie, msg *Message)

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

The function takes the following parameters:

  • cookies of Cookie.
  • msg: Message.

func DateTimeNewFromHTTPString

func DateTimeNewFromHTTPString(dateString string) *glib.DateTime

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

The function takes the following parameters:

  • dateString: date as a string.

The function returns the following values:

  • dateTime (optional): new Time, or NULL if date_string could not be parsed.

func DateTimeToString

func DateTimeToString(date *glib.DateTime, format DateFormat) string

DateTimeToString converts date to a string in the format described by format.

The function takes the following parameters:

  • date: Time.
  • format to generate the date in.

The function returns the following values:

  • utf8: date as a string or NULL.

func FormDecode

func FormDecode(encodedForm string) map[string]string

FormDecode decodes form.

which is an urlencoded dataset as defined in the HTML 4.01 spec.

The function takes the following parameters:

  • encodedForm: data of type "application/x-www-form-urlencoded".

The function returns the following values:

  • hashTable: hash table containing the name/value pairs from encoded_form, which you can free with glib.HashTable().Destroy.

func FormDecodeMultipart

func FormDecodeMultipart(multipart *Multipart, fileControlName string) (filename, contentType string, file *glib.Bytes, hashTable map[string]string)

FormDecodeMultipart 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 glib.HashTable.

You may pass NULL for filename, content_type and/or file if you do not care about those fields. 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 glib.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.NewFromMessage and multipart.GetPart.

The function takes the following parameters:

  • multipart: Multipart.
  • fileControlName (optional): name of the HTML file upload control.

The function returns the following values:

  • filename (optional): return location for the name of the uploaded file.
  • contentType (optional): return location for the MIME type of the uploaded file.
  • file (optional): return location for the uploaded file data.
  • hashTable (optional): a hash table containing the name/value pairs (other than file_control_name) from msg, which you can free with glib.HashTable().Destroy. On error, it will return NULL.

func FormEncodeHash

func FormEncodeHash(formDataSet map[string]string) string

FormEncodeHash 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.NewFromEncodedForm.

The function takes the following parameters:

  • formDataSet: hash table containing name/value pairs (as strings).

The function returns the following values:

  • utf8: encoded form.

func GetMajorVersion

func GetMajorVersion() uint

GetMajorVersion 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 UP_MAJOR_VERSION macro, which represents the major version of the libsoup headers you have included when compiling your code.

The function returns the following values:

  • guint: major version number of the libsoup library.

func GetMicroVersion

func GetMicroVersion() uint

GetMicroVersion 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 UP_MICRO_VERSION macro, which represents the micro version of the libsoup headers you have included when compiling your code.

The function returns the following values:

  • guint: micro version number of the libsoup library.

func GetMinorVersion

func GetMinorVersion() uint

GetMinorVersion 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 UP_MINOR_VERSION macro, which represents the minor version of the libsoup headers you have included when compiling your code.

The function returns the following values:

  • guint: minor version number of the libsoup library.

func HeaderContains

func HeaderContains(header, token string) bool

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

The function takes the following parameters:

  • header: HTTP header suitable for parsing with header_parse_list.
  • token: token.

The function returns the following values:

  • ok: whether or not header contains token.

func HeaderFreeParamList

func HeaderFreeParamList(paramList map[string]string)

HeaderFreeParamList frees param_list.

The function takes the following parameters:

  • paramList returned from header_parse_param_list or header_parse_semi_param_list.

func HeaderParseList

func HeaderParseList(header string) []string

HeaderParseList parses a header whose content is described by RFC2616 as #something.

"something" does not itself contain commas, except as part of quoted-strings.

The function takes the following parameters:

  • header value.

The function returns the following values:

  • sList of list elements, as allocated strings.

func HeaderParseParamList

func HeaderParseParamList(header string) map[string]string

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

The function takes the following parameters:

  • header value.

The function returns the following values:

  • hashTable: a Table of list elements, which can be freed with header_free_param_list.

func HeaderParseParamListStrict

func HeaderParseParamListStrict(header string) map[string]string

HeaderParseParamListStrict: 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.

The function takes the following parameters:

  • header value.

The function returns the following values:

  • hashTable (optional): a Table of list elements, which can be freed with header_free_param_list or NULL if there are duplicate elements.

func HeaderParseQualityList

func HeaderParseQualityList(header string) (unacceptable, sList []string)

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

The function takes the following parameters:

  • header value.

The function returns the following values:

  • unacceptable (optional): on return, will contain a list of unacceptable values.
  • sList of acceptable values (as allocated strings), highest-qvalue first.

func HeaderParseSemiParamList

func HeaderParseSemiParamList(header string) map[string]string

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

The function takes the following parameters:

  • header value.

The function returns the following values:

  • hashTable: a Table of list elements, which can be freed with header_free_param_list.

func HeaderParseSemiParamListStrict

func HeaderParseSemiParamListStrict(header string) map[string]string

HeaderParseSemiParamListStrict: 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.

The function takes the following parameters:

  • header value.

The function returns the following values:

  • hashTable (optional): a Table of list elements, which can be freed with header_free_param_list or NULL if there are duplicate elements.

func HeadersParse

func HeadersParse(str string, len int, dest *MessageHeaders) bool

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

The function takes the following parameters:

  • str: header string (including the Request-Line or Status-Line, but not the trailing blank line).
  • len: length of str.
  • dest to store the header values in.

The function returns the following values:

  • ok success or failure.

func SessionErrorQuark

func SessionErrorQuark() glib.Quark

SessionErrorQuark registers error quark for SoupSession if needed.

The function returns the following values:

  • quark: error quark for SoupSession.

func StatusGetPhrase

func StatusGetPhrase(statusCode uint) string

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

The function takes the following parameters:

  • statusCode: HTTP status code.

The function returns the following values:

  • utf8: (terse, English) description of status_code.

func TLDErrorQuark

func TLDErrorQuark() glib.Quark

TLDErrorQuark registers error quark for soup_tld_get_base_domain() if needed.

The function returns the following values:

  • quark: error quark for Soup TLD functions.

func TldDomainIsPublicSuffix

func TldDomainIsPublicSuffix(domain string) bool

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

The function takes the following parameters:

  • domain name.

The function returns the following values:

  • ok: TRUE if it is a public domain, FALSE otherwise.

func TldGetBaseDomain

func TldGetBaseDomain(hostname string) (string, error)

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

The function takes the following parameters:

  • hostname: hostname.

The function returns the following values:

  • utf8: pointer to the start of the base domain in hostname. If an error occurs, NULL will be returned and error set.

func URIDecodeDataURI

func URIDecodeDataURI(uri string) (string, *glib.Bytes)

URIDecodeDataURI decodes the given data URI and returns its contents and content_type.

The function takes the following parameters:

  • uri: data URI, in string form.

The function returns the following values:

  • contentType (optional): location to store content type.
  • bytes with the contents of uri, or NULL if uri is not a valid data URI.

func URIEqual

func URIEqual(uri1, uri2 *glib.URI) bool

URIEqual tests whether or not uri1 and uri2 are equal in all parts.

The function takes the following parameters:

  • uri1: #GUri.
  • uri2: another #GUri.

The function returns the following values:

  • ok: TRUE if equal otherwise FALSE.

func WebsocketErrorQuark

func WebsocketErrorQuark() glib.Quark

WebsocketErrorQuark registers error quark for SoupWebsocket if needed.

The function returns the following values:

  • quark: error quark for SoupWebsocket.

Types

type Auth

type Auth struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

Auth: abstract base class for handling authentication.

Specific HTTP Authentication mechanisms are implemented by its subclasses, but applications never need to be aware of the specific subclasses being used.

Auth objects store the authentication data associated with a given bit of web space. They are created automatically by session.

func BaseAuth

func BaseAuth(obj Auther) *Auth

BaseAuth returns the underlying base object.

func NewAuth

func NewAuth(typ coreglib.Type, msg *Message, authHeader string) *Auth

NewAuth creates a new Auth of type type with the information from msg and auth_header.

This is called by session; you will normally not create auths yourself.

The function takes the following parameters:

  • typ: type of auth to create (a subtype of Auth).
  • msg the auth is being created for.
  • authHeader: WWW-Authenticate/Proxy-Authenticate header.

The function returns the following values:

  • auth (optional): new Auth, or NULL if it could not be created.

func (*Auth) Authenticate

func (auth *Auth) Authenticate(username, password string)

Authenticate: call this on an auth to authenticate it.

Normally this will cause the auth's message to be requeued with the new authentication info.

The function takes the following parameters:

  • username provided by the user or client.
  • password provided by the user or client.

func (*Auth) Authority

func (auth *Auth) Authority() string

Authority returns the authority (host:port) that auth is associated with.

The function returns the following values:

  • utf8: authority.

func (*Auth) Authorization

func (auth *Auth) Authorization(msg *Message) string

Authorization generates an appropriate "Authorization" header for msg.

(The session will only call this if auth.IsAuthenticated returned TRUE.).

The function takes the following parameters:

  • msg to be authorized.

The function returns the following values:

  • utf8: "Authorization" header, which must be freed.

func (*Auth) CanAuthenticate

func (auth *Auth) CanAuthenticate() bool

CanAuthenticate tests if auth is able to authenticate by providing credentials to the auth.Authenticate.

The function returns the following values:

  • ok: TRUE if auth is able to accept credentials.

func (*Auth) Cancel

func (auth *Auth) Cancel()

Cancel: call this on an auth to cancel it.

You need to cancel an auth to complete an asynchronous authenticate operation when no credentials are provided (auth.Authenticate is not called). The Auth will be cancelled on dispose if it hans't been authenticated.

func (*Auth) Info

func (auth *Auth) Info() string

Info gets an opaque identifier for auth.

The identifier can be used as a hash key or the like. Auth objects from the same server with the same identifier refer to the same authentication domain (eg, the URLs associated with them take the same usernames and passwords).

The function returns the following values:

  • utf8: identifier.

func (*Auth) IsAuthenticated

func (auth *Auth) IsAuthenticated() bool

IsAuthenticated tests if auth has been given a username and password.

The function returns the following values:

  • ok: TRUE if auth has been given a username and password.

func (*Auth) IsCancelled

func (auth *Auth) IsCancelled() bool

IsCancelled tests if auth has been cancelled.

The function returns the following values:

  • ok: TRUE if auth has been cancelled.

func (*Auth) IsForProxy

func (auth *Auth) IsForProxy() bool

IsForProxy tests whether or not auth is associated with a proxy server rather than an "origin" server.

The function returns the following values:

  • ok: TRUE or FALSE.

func (*Auth) IsReady

func (auth *Auth) IsReady(msg *Message) bool

IsReady tests if auth is ready to make a request for msg with.

For most auths, this is equivalent to auth.IsAuthenticated, but for some auth types (eg, NTLM), the auth may be sendable (eg, as an authentication request) even before it is authenticated.

The function takes the following parameters:

  • msg: Message.

The function returns the following values:

  • ok: TRUE if auth is ready to make a request with.

func (*Auth) ProtectionSpace

func (auth *Auth) ProtectionSpace(sourceUri *glib.URI) []string

ProtectionSpace returns a list of paths on the server which auth extends over.

(All subdirectories of these paths are also assumed to be part of auth's protection space, unless otherwise discovered not to be.).

The function takes the following parameters:

  • sourceUri: URI of the request that auth was generated in response to.

The function returns the following values:

  • sList: list of paths, which can be freed with auth.FreeProtectionSpace.

func (*Auth) Realm

func (auth *Auth) Realm() string

Realm returns auth's realm.

This is an identifier that distinguishes separate authentication spaces on a given server, and may be some string that is meaningful to the user. (Although it is probably not localized.).

The function returns the following values:

  • utf8: realm name.

func (*Auth) SchemeName

func (auth *Auth) SchemeName() string

SchemeName: soup_auth_get_scheme_name: (attributes org.gtk.Method.get_property=scheme-name) Returns auth's scheme name. (Eg, "Basic", "Digest", or "NTLM").

The function returns the following values:

  • utf8: scheme name.

func (*Auth) Update

func (auth *Auth) Update(msg *Message, authHeader string) bool

Update updates auth with the information from msg and auth_header, possibly un-authenticating it.

As with auth.New, this is normally only used by session.

The function takes the following parameters:

  • msg auth is being updated for.
  • authHeader: WWW-Authenticate/Proxy-Authenticate header.

The function returns the following values:

  • ok: TRUE if auth is still a valid (but potentially unauthenticated) Auth. FALSE if something about auth_params could not be parsed or incorporated into auth at all.

type AuthBasic

type AuthBasic struct {
	Auth
	// contains filtered or unexported fields
}

AuthBasic: HTTP "Basic" authentication.

sessions support this by default; if you want to disable support for it, call session.RemoveFeatureByType, passing SOUP_TYPE_AUTH_BASIC.

type AuthClass

type AuthClass struct {
	// contains filtered or unexported fields
}

AuthClass: instance of this type is always passed by reference.

func (*AuthClass) Padding

func (a *AuthClass) Padding() [6]unsafe.Pointer

func (*AuthClass) SchemeName

func (a *AuthClass) SchemeName() string

func (*AuthClass) Strength

func (a *AuthClass) Strength() uint

type AuthDigest

type AuthDigest struct {
	Auth
	// contains filtered or unexported fields
}

AuthDigest: HTTP "Digest" authentication.

sessions support this by default; if you want to disable support for it, call session.RemoveFeatureByType passing SOUP_TYPE_AUTH_DIGEST.

type AuthDomain

type AuthDomain struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

AuthDomain: server-side authentication.

A AuthDomain manages authentication for all or part of a server. To make a server require authentication, first create an appropriate subclass of AuthDomain, and then add it to the server with server.AddAuthDomain.

In order for an auth domain to have any effect, you must add one or more paths to it (via authdomain.AddPath). To require authentication for all ordinary requests, add the path "/". (Note that this does not include the special "*" URI (eg, "OPTIONS *"), which must be added as a separate path if you want to cover it.)

If you need greater control over which requests should and shouldn't be authenticated, add paths covering everything you *might* want authenticated, and then use a filter (authdomain.SetFilter to bypass authentication for those requests that don't need it.

func BaseAuthDomain

func BaseAuthDomain(obj AuthDomainer) *AuthDomain

BaseAuthDomain returns the underlying base object.

func (*AuthDomain) Accepts

func (domain *AuthDomain) Accepts(msg *ServerMessage) string

Accepts checks if msg contains appropriate authorization for domain to accept it.

Mirroring authdomain.Covers, this does not check whether or not domain *cares* if msg is authorized.

This is used by server internally and is probably of no use to anyone else.

The function takes the following parameters:

  • msg: ServerMessage.

The function returns the following values:

  • utf8 (optional): username that msg has authenticated as, if in fact it has authenticated. NULL otherwise.

func (*AuthDomain) AddPath

func (domain *AuthDomain) AddPath(path string)

AddPath adds path to domain.

Requests under path on domain's server will require authentication (unless overridden by authdomain.RemovePath or authdomain.SetFilter).

The function takes the following parameters:

  • path to add to domain.

func (*AuthDomain) Challenge

func (domain *AuthDomain) Challenge(msg *ServerMessage)

Challenge adds a "WWW-Authenticate" or "Proxy-Authenticate" header to msg.

It requests that the client authenticate, and sets msg's status accordingly.

This is used by server internally and is probably of no use to anyone else.

The function takes the following parameters:

  • msg: ServerMessage.

func (*AuthDomain) CheckPassword

func (domain *AuthDomain) CheckPassword(msg *ServerMessage, username, password string) bool

CheckPassword checks if msg authenticates to domain via username and password.

This would normally be called from a authdomaingenericauthcallback.

The function takes the following parameters:

  • msg: ServerMessage.
  • username: username.
  • password: password.

The function returns the following values:

  • ok: whether or not the message is authenticated.

func (*AuthDomain) Covers

func (domain *AuthDomain) Covers(msg *ServerMessage) bool

Covers checks if domain requires msg to be authenticated (according to its paths and filter function).

This does not actually look at whether msg *is* authenticated, merely whether or not it needs to be.

This is used by server internally and is probably of no use to anyone else.

The function takes the following parameters:

  • msg: ServerMessage.

The function returns the following values:

  • ok: TRUE if domain requires msg to be authenticated.

func (*AuthDomain) Realm

func (domain *AuthDomain) Realm() string

Realm gets the realm name associated with domain.

The function returns the following values:

  • utf8 domain's realm.

func (*AuthDomain) RemovePath

func (domain *AuthDomain) RemovePath(path string)

RemovePath removes path from domain.

Requests under path on domain's server will NOT require authentication.

This is not simply an undo-er for authdomain.AddPath; it can be used to "carve out" a subtree that does not require authentication inside a hierarchy that does. Note also that unlike with authdomain.AddPath, this cannot be overridden by adding a filter, as filters can only bypass authentication that would otherwise be required, not require it where it would otherwise be unnecessary.

The function takes the following parameters:

  • path to remove from domain.

func (*AuthDomain) SetFilter

func (domain *AuthDomain) SetFilter(filter AuthDomainFilter)

SetFilter adds filter as an authentication filter to domain.

The filter gets a chance to bypass authentication for certain requests that would otherwise require it. Eg, it might check the message's path in some way that is too complicated to do via the other methods, or it might check the message's method, and allow GETs but not PUTs.

The filter function returns TRUE if the request should still require authentication, or FALSE if authentication is unnecessary for this request.

To help prevent security holes, your filter should return TRUE by default, and only return FALSE under specifically-tested circumstances, rather than the other way around. Eg, in the example above, where you want to authenticate PUTs but not GETs, you should check if the method is GET and return FALSE in that case, and then return TRUE for all other methods (rather than returning TRUE for PUT and FALSE for all other methods). This way if it turned out (now or later) that some paths supported additional methods besides GET and PUT, those methods would default to being NOT allowed for unauthenticated users.

You can also set the filter by setting the SoupAuthDomain:filter and authdomain:filter-data properties, which can also be used to set the filter at construct time.

The function takes the following parameters:

  • filter: auth filter for domain.

func (*AuthDomain) SetGenericAuthCallback

func (domain *AuthDomain) SetGenericAuthCallback(authCallback AuthDomainGenericAuthCallback)

SetGenericAuthCallback sets auth_callback as an authentication-handling callback for domain.

Whenever a request comes in to domain which cannot be authenticated via a domain-specific auth callback (eg, authdomaindigestauthcallback), the generic auth callback will be invoked. See authdomaingenericauthcallback for information on what the callback should do.

The function takes the following parameters:

  • authCallback: auth callback.

type AuthDomainBasic

type AuthDomainBasic struct {
	AuthDomain
	// contains filtered or unexported fields
}

AuthDomainBasic: server-side "Basic" authentication.

AuthDomainBasic handles the server side of HTTP "Basic" (ie, cleartext password) authentication.

func (*AuthDomainBasic) SetAuthCallback

func (domain *AuthDomainBasic) SetAuthCallback(callback AuthDomainBasicAuthCallback)

SetAuthCallback sets the callback that domain will use to authenticate incoming requests.

For each request containing authorization, domain will invoke the callback, and then either accept or reject the request based on callback's return value.

You can also set the auth callback by setting the authdomainbasic:auth-callback and authdomainbasic:auth-data properties, which can also be used to set the callback at construct time.

The function takes the following parameters:

  • callback: callback.

type AuthDomainBasicAuthCallback

type AuthDomainBasicAuthCallback func(domain *AuthDomainBasic, msg *ServerMessage, username, password string) (ok bool)

AuthDomainBasicAuthCallback: callback used by AuthDomainBasic 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.

type AuthDomainBasicClass

type AuthDomainBasicClass struct {
	// contains filtered or unexported fields
}

AuthDomainBasicClass: instance of this type is always passed by reference.

func (*AuthDomainBasicClass) ParentClass

func (a *AuthDomainBasicClass) ParentClass() *AuthDomainClass

type AuthDomainBasicOverrides

type AuthDomainBasicOverrides struct {
}

AuthDomainBasicOverrides contains methods that are overridable.

type AuthDomainClass

type AuthDomainClass struct {
	// contains filtered or unexported fields
}

AuthDomainClass: instance of this type is always passed by reference.

func (*AuthDomainClass) Padding

func (a *AuthDomainClass) Padding() [6]unsafe.Pointer

type AuthDomainDigest

type AuthDomainDigest struct {
	AuthDomain
	// contains filtered or unexported fields
}

AuthDomainDigest: server-side "Digest" authentication.

AuthDomainDigest handles the server side of HTTP "Digest" authentication.

func (*AuthDomainDigest) SetAuthCallback

func (domain *AuthDomainDigest) SetAuthCallback(callback AuthDomainDigestAuthCallback)

SetAuthCallback sets the callback that domain will use to authenticate incoming requests.

For each request containing authorization, domain will invoke the callback, and then either accept or reject the request based on callback's return value.

You can also set the auth callback by setting the authdomaindigest:auth-callback and authdomaindigest:auth-data properties, which can also be used to set the callback at construct time.

The function takes the following parameters:

  • callback: callback.

type AuthDomainDigestAuthCallback

type AuthDomainDigestAuthCallback func(domain *AuthDomainDigest, msg *ServerMessage, username string) (utf8 string)

AuthDomainDigestAuthCallback: callback used by AuthDomainDigest for authentication purposes.

The application should look up username in its password database, and return the corresponding encoded password (see authdomaindigest.EncodePassword().

type AuthDomainDigestClass

type AuthDomainDigestClass struct {
	// contains filtered or unexported fields
}

AuthDomainDigestClass: instance of this type is always passed by reference.

func (*AuthDomainDigestClass) ParentClass

func (a *AuthDomainDigestClass) ParentClass() *AuthDomainClass

type AuthDomainDigestOverrides

type AuthDomainDigestOverrides struct {
}

AuthDomainDigestOverrides contains methods that are overridable.

type AuthDomainFilter

type AuthDomainFilter func(domain AuthDomainer, msg *ServerMessage) (ok bool)

AuthDomainFilter: prototype for a AuthDomain filter.

See authdomain.SetFilter for details.

type AuthDomainGenericAuthCallback

type AuthDomainGenericAuthCallback func(domain AuthDomainer, msg *ServerMessage, username string) (ok bool)

AuthDomainGenericAuthCallback: prototype for a AuthDomain generic authentication callback.

The callback should look up the user's password, call authdomain.CheckPassword, and use the return value from that method as its own return value.

In general, for security reasons, it is preferable to use the auth-domain-specific auth callbacks (eg, authdomainbasicauthcallback and authdomaindigestauthcallback), because they don't require keeping a cleartext password database. Most users will use the same password for many different sites, meaning if any site with a cleartext password database is compromised, accounts on other servers might be compromised as well. For many of the cases where server is used, this is not really relevant, but it may still be worth considering.

type AuthDomainOverrides

type AuthDomainOverrides struct {
	// The function takes the following parameters:
	//
	//   - msg
	//   - header
	//
	// The function returns the following values:
	//
	Accepts func(msg *ServerMessage, header string) string
	// Challenge adds a "WWW-Authenticate" or "Proxy-Authenticate" header to
	// msg.
	//
	// It requests that the client authenticate, and sets msg's status
	// accordingly.
	//
	// This is used by server internally and is probably of no use to anyone
	// else.
	//
	// The function takes the following parameters:
	//
	//   - msg: ServerMessage.
	//
	// The function returns the following values:
	//
	Challenge func(msg *ServerMessage) string
	// CheckPassword checks if msg authenticates to domain via username and
	// password.
	//
	// This would normally be called from a authdomaingenericauthcallback.
	//
	// The function takes the following parameters:
	//
	//   - msg: ServerMessage.
	//   - username: username.
	//   - password: password.
	//
	// The function returns the following values:
	//
	//   - ok: whether or not the message is authenticated.
	//
	CheckPassword func(msg *ServerMessage, username, password string) bool
}

AuthDomainOverrides contains methods that are overridable.

type AuthDomainer

type AuthDomainer interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

AuthDomainer describes types inherited from class AuthDomain.

To get the original type, the caller must assert this to an interface or another type.

type AuthManager

type AuthManager struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

AuthManager: HTTP client-side authentication handler.

AuthManager is the sessionfeature that handles HTTP authentication for a session.

A AuthManager is added to the session by default, and normally you don't need to worry about it at all. However, if you want to disable HTTP authentication, you can remove the feature from the session with session.RemoveFeatureByType or disable it on individual requests with message.DisableFeature.

You can use this with session.RemoveFeatureByType or message.DisableFeature.

(Although this type has only been publicly visible since libsoup 2.42, it has always existed in the background, and you can use g_type_from_name ("SoupAuthManager") to get its glib.Type in earlier releases.).

func (*AuthManager) ClearCachedCredentials

func (manager *AuthManager) ClearCachedCredentials()

ClearCachedCredentials: clear all credentials cached by manager.

func (*AuthManager) UseAuth

func (manager *AuthManager) UseAuth(uri *glib.URI, auth Auther)

UseAuth records that auth is to be used under uri, as though a WWW-Authenticate header had been received at that URI.

This can be used to "preload" manager's auth cache, to avoid an extra HTTP round trip in the case where you know ahead of time that a 401 response will be returned.

This is only useful for authentication types where the initial Authorization header does not depend on any additional information from the server. (Eg, Basic or NTLM, but not Digest.).

The function takes the following parameters:

  • uri under which auth is to be used.
  • auth to use.

type AuthManagerClass

type AuthManagerClass struct {
	// contains filtered or unexported fields
}

AuthManagerClass: instance of this type is always passed by reference.

type AuthManagerOverrides

type AuthManagerOverrides struct {
}

AuthManagerOverrides contains methods that are overridable.

type AuthNTLM

type AuthNTLM struct {
	Auth
	// contains filtered or unexported fields
}

AuthNTLM: HTTP-based NTLM authentication.

sessions do not support this type by default; if you want to enable support for it, call session.AddFeatureByType, passing SOUP_TYPE_AUTH_NTLM.

type AuthNegotiate

type AuthNegotiate struct {
	Auth
	// contains filtered or unexported fields
}

AuthNegotiate: HTTP-based GSS-Negotiate authentication, as defined by RFC 4559 (https://datatracker.ietf.org/doc/html/rfc4559).

sessions do not support this type by default; if you want to enable support for it, call session.AddFeatureByType, passing SOUP_TYPE_AUTH_NEGOTIATE.

This auth type will only work if libsoup was compiled with GSSAPI support; you can check authnegotiate.Supported() to see if it was.

type AuthOverrides

type AuthOverrides struct {
	// Authenticate: call this on an auth to authenticate it.
	//
	// Normally this will cause the auth's message to be requeued with the new
	// authentication info.
	//
	// The function takes the following parameters:
	//
	//   - username provided by the user or client.
	//   - password provided by the user or client.
	//
	Authenticate func(username, password string)
	// CanAuthenticate tests if auth is able to authenticate by providing
	// credentials to the auth.Authenticate.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if auth is able to accept credentials.
	//
	CanAuthenticate func() bool
	// Authorization generates an appropriate "Authorization" header for msg.
	//
	// (The session will only call this if auth.IsAuthenticated returned TRUE.).
	//
	// The function takes the following parameters:
	//
	//   - msg to be authorized.
	//
	// The function returns the following values:
	//
	//   - utf8: "Authorization" header, which must be freed.
	//
	Authorization func(msg *Message) string
	// ProtectionSpace returns a list of paths on the server which auth extends
	// over.
	//
	// (All subdirectories of these paths are also assumed to be part of auth's
	// protection space, unless otherwise discovered not to be.).
	//
	// The function takes the following parameters:
	//
	//   - sourceUri: URI of the request that auth was generated in response to.
	//
	// The function returns the following values:
	//
	//   - sList: list of paths, which can be freed with
	//     auth.FreeProtectionSpace.
	//
	ProtectionSpace func(sourceUri *glib.URI) []string
	// IsAuthenticated tests if auth has been given a username and password.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if auth has been given a username and password.
	//
	IsAuthenticated func() bool
	// IsReady tests if auth is ready to make a request for msg with.
	//
	// For most auths, this is equivalent to auth.IsAuthenticated, but for some
	// auth types (eg, NTLM), the auth may be sendable (eg, as an authentication
	// request) even before it is authenticated.
	//
	// The function takes the following parameters:
	//
	//   - msg: Message.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if auth is ready to make a request with.
	//
	IsReady func(msg *Message) bool
	// Update updates auth with the information from msg and auth_header,
	// possibly un-authenticating it.
	//
	// As with auth.New, this is normally only used by session.
	//
	// The function takes the following parameters:
	//
	//   - msg auth is being updated for.
	//   - authHeader: WWW-Authenticate/Proxy-Authenticate header.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if auth is still a valid (but potentially unauthenticated)
	//     Auth. FALSE if something about auth_params could not be parsed or
	//     incorporated into auth at all.
	//
	Update func(msg *Message, authHeader map[unsafe.Pointer]unsafe.Pointer) bool
}

AuthOverrides contains methods that are overridable.

type Auther

type Auther interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

Auther describes types inherited from class Auth.

To get the original type, the caller must assert this to an interface or another type.

type Cache

type Cache struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

Cache: file-based cache for HTTP resources.

func NewCache

func NewCache(cacheDir string, cacheType CacheType) *Cache

NewCache creates a new Cache.

The function takes the following parameters:

  • cacheDir (optional): directory to store the cached data, or NULL to use the default one. Note that since the cache isn't safe to access for multiple processes at once, and the default directory isn't namespaced by process, clients are strongly discouraged from passing NULL.
  • cacheType of the cache.

The function returns the following values:

  • cache: new Cache.

func (*Cache) Clear

func (cache *Cache) Clear()

Clear will remove all entries in the cache plus all the cache files.

This is not thread safe and must be called only from the thread that created the Cache.

func (*Cache) Dump

func (cache *Cache) Dump()

Dump: synchronously writes the cache index out to disk.

Contrast with cache.Flush, which writes pending cache *entries* to disk.

You must call this before exiting if you want your cache data to persist between sessions.

This is not thread safe and must be called only from the thread that created the Cache.

func (*Cache) Flush

func (cache *Cache) Flush()

Flush forces all pending writes in the cache to be committed to disk.

For doing so it will iterate the glib.MainContext associated with cache's session as long as needed.

Contrast with cache.Dump, which writes out the cache index file.

func (*Cache) Load

func (cache *Cache) Load()

Load loads the contents of cache's index into memory.

This is not thread safe and must be called only from the thread that created the Cache.

func (*Cache) MaxSize

func (cache *Cache) MaxSize() uint

MaxSize gets the maximum size of the cache.

The function returns the following values:

  • guint: maximum size of the cache, in bytes.

func (*Cache) SetMaxSize

func (cache *Cache) SetMaxSize(maxSize uint)

SetMaxSize sets the maximum size of the cache.

The function takes the following parameters:

  • maxSize: maximum size of the cache, in bytes.

type CacheClass

type CacheClass struct {
	// contains filtered or unexported fields
}

CacheClass: instance of this type is always passed by reference.

func (*CacheClass) Padding

func (c *CacheClass) Padding() [4]unsafe.Pointer

type CacheOverrides

type CacheOverrides struct {
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Cacheability func(msg *Message) Cacheability
}

CacheOverrides contains methods that are overridable.

type CacheType

type CacheType C.gint

CacheType: type of cache; this affects what kinds of responses will be saved.

const (
	// CacheSingleUser: single-user cache.
	CacheSingleUser CacheType = iota
	// CacheShared: shared cache.
	CacheShared
)

func (CacheType) String

func (c CacheType) String() string

String returns the name in string for CacheType.

type Cacheability

type Cacheability C.guint

Cacheability indicates if a message should or shouldn't be cached.

const (
	// CacheCacheable: message should be cached.
	CacheCacheable Cacheability = 0b1
	// CacheUncacheable: message shouldn't be cached.
	CacheUncacheable Cacheability = 0b10
	// CacheInvalidates messages cache should be invalidated.
	CacheInvalidates Cacheability = 0b100
	// CacheValidates messages cache should be updated.
	CacheValidates Cacheability = 0b1000
)

func (Cacheability) Has

func (c Cacheability) Has(other Cacheability) bool

Has returns true if c contains other.

func (Cacheability) String

func (c Cacheability) String() string

String returns the names in string for Cacheability.

type ContentDecoder

type ContentDecoder struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

ContentDecoder handles decoding of HTTP messages.

ContentDecoder handles adding the "Accept-Encoding" header on outgoing messages, and processing the "Content-Encoding" header on incoming ones. Currently it supports the "gzip", "deflate", and "br" content codings.

A ContentDecoder will automatically be added to the session by default. (You can use session.RemoveFeatureByType if you don't want this.)

If ContentDecoder successfully decodes the Content-Encoding, the message body will contain the decoded data; however, the message headers will be unchanged (and so "Content-Encoding" will still be present, "Content-Length" will describe the original encoded length, etc).

If "Content-Encoding" contains any encoding types that ContentDecoder doesn't recognize, then none of the encodings will be decoded.

(Note that currently there is no way to (automatically) use Content-Encoding when sending a request body, or to pick specific encoding types to support.).

type ContentDecoderClass

type ContentDecoderClass struct {
	// contains filtered or unexported fields
}

ContentDecoderClass: instance of this type is always passed by reference.

type ContentDecoderOverrides

type ContentDecoderOverrides struct {
}

ContentDecoderOverrides contains methods that are overridable.

type ContentSniffer

type ContentSniffer struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

ContentSniffer sniffs the mime type of messages.

A ContentSniffer tries to detect the actual content type of the files that are being downloaded by looking at some of the data before the message emits its message::got-headers signal. ContentSniffer implements sessionfeature, so you can add content sniffing to a session with session.AddFeature or session.AddFeatureByType.

func NewContentSniffer

func NewContentSniffer() *ContentSniffer

NewContentSniffer creates a new ContentSniffer.

The function returns the following values:

  • contentSniffer: new ContentSniffer.

func (*ContentSniffer) Sniff

func (sniffer *ContentSniffer) Sniff(msg *Message, buffer *glib.Bytes) (map[string]string, string)

Sniff sniffs buffer to determine its Content-Type.

The result may also be influenced by the Content-Type declared in msg's response headers.

The function takes the following parameters:

  • msg: message to sniff.
  • buffer containing the start of msg's response body.

The function returns the following values:

  • params (optional): return location for Content-Type parameters (eg, "charset"), or NULL.
  • utf8: sniffed Content-Type of buffer; this will never be NULL, but may be application/octet-stream.

type ContentSnifferClass

type ContentSnifferClass struct {
	// contains filtered or unexported fields
}

ContentSnifferClass: instance of this type is always passed by reference.

type ContentSnifferOverrides

type ContentSnifferOverrides struct {
}

ContentSnifferOverrides contains methods that are overridable.

type Cookie struct {
	// contains filtered or unexported fields
}

Cookie implements HTTP cookies, as described by RFC 6265 (http://tools.ietf.org/html/rfc6265.txt).

To have a session handle cookies for your appliction automatically, use a cookiejar.

name and value will be set for all cookies. If the cookie is generated from a string that appears to have no name, then name will be the empty string.

domain and path give the host or domain, and path within that host/domain, to restrict this cookie to. If domain starts with ".", that indicates a domain (which matches the string after the ".", or any hostname that has domain as a suffix). Otherwise, it is a hostname and must match exactly.

expires will be non-NULL if the cookie uses either the original "expires" attribute, or the newer "max-age" attribute. If expires is NULL, it indicates that neither "expires" nor "max-age" was specified, and the cookie expires at the end of the session.

If http_only is set, the cookie should not be exposed to untrusted code (eg, javascript), so as to minimize the danger posed by cross-site scripting attacks.

An instance of this type is always passed by reference.

func CookieParse

func CookieParse(header string, origin *glib.URI) *Cookie

CookieParse 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 NULL, path will default to "/", but domain will be left as NULL. 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 SOUP_SAME_SITE_POLICY_LAX.

The function takes the following parameters:

  • header: cookie string (eg, the value of a Set-Cookie header).
  • origin (optional) of the cookie.

The function returns the following values:

  • cookie (optional): new Cookie, or NULL if it could not be parsed, or contained an illegal "domain" attribute for a cookie originating from origin.

func CookiesFromRequest

func CookiesFromRequest(msg *Message) []*Cookie

CookiesFromRequest parses msg's Cookie request header and returns a glib.SList of SoupCookies.

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

The function takes the following parameters:

  • msg containing a "Cookie" request header.

The function returns the following values:

  • sList of SoupCookies, which can be freed with cookie.Free.

func CookiesFromResponse

func CookiesFromResponse(msg *Message) []*Cookie

CookiesFromResponse parses msg's Set-Cookie response headers and returns a glib.SList of SoupCookies.

Cookies that do not specify "path" or "domain" attributes will have their values defaulted from msg.

The function takes the following parameters:

  • msg containing a "Set-Cookie" response header.

The function returns the following values:

  • sList of SoupCookies, which can be freed with cookie.Free.

func NewCookie

func NewCookie(name string, value string, domain string, path string, maxAge int) *Cookie

NewCookie constructs a struct Cookie.

func (*Cookie) AppliesToURI

func (cookie *Cookie) AppliesToURI(uri *glib.URI) bool

AppliesToURI tests if cookie should be sent to uri.

(At the moment, this does not check that cookie's domain matches uri, because it assumes that the caller has already done that. But don't rely on that; it may change in the future.).

The function takes the following parameters:

  • uri: #GUri.

The function returns the following values:

  • ok: TRUE if cookie should be sent to uri, FALSE if not.

func (*Cookie) Copy

func (cookie *Cookie) Copy() *Cookie

Copy copies cookie.

The function returns the following values:

  • ret: copy of cookie.

func (*Cookie) Domain

func (cookie *Cookie) Domain() string

Domain gets cookie's domain.

The function returns the following values:

  • utf8 cookie's domain.

func (*Cookie) DomainMatches

func (cookie *Cookie) DomainMatches(host string) bool

DomainMatches checks if the cookie's domain and host match.

The domains match if cookie should be sent when making a request to host, or that cookie should be accepted when receiving a response from host.

The function takes the following parameters:

  • host: URI.

The function returns the following values:

  • ok: TRUE if the domains match, FALSE otherwise.

func (*Cookie) Equal

func (cookie1 *Cookie) Equal(cookie2 *Cookie) bool

Equal tests if cookie1 and cookie2 are equal.

Note that currently, this does not check that the cookie domains match. This may change in the future.

The function takes the following parameters:

  • cookie2: Cookie.

The function returns the following values:

  • ok: whether the cookies are equal.

func (*Cookie) Expires

func (cookie *Cookie) Expires() *glib.DateTime

Expires gets cookie's expiration time.

The function returns the following values:

  • dateTime (optional) cookie's expiration time, which is owned by cookie and should not be modified or freed.

func (*Cookie) HTTPOnly

func (cookie *Cookie) HTTPOnly() bool

HTTPOnly gets cookie's HttpOnly attribute.

The function returns the following values:

  • ok cookie's HttpOnly attribute.

func (*Cookie) Name

func (cookie *Cookie) Name() string

Name gets cookie's name.

The function returns the following values:

  • utf8 cookie's name.

func (*Cookie) Path

func (cookie *Cookie) Path() string

Path gets cookie's path.

The function returns the following values:

  • utf8 cookie's path.

func (*Cookie) SameSitePolicy

func (cookie *Cookie) SameSitePolicy() SameSitePolicy

SameSitePolicy returns the same-site policy for this cookie.

The function returns the following values:

  • sameSitePolicy: SameSitePolicy.

func (*Cookie) Secure

func (cookie *Cookie) Secure() bool

Secure gets cookie's secure attribute.

The function returns the following values:

  • ok cookie's secure attribute.

func (*Cookie) SetDomain

func (cookie *Cookie) SetDomain(domain string)

SetDomain sets cookie's domain to domain.

The function takes the following parameters:

  • domain: new domain.

func (*Cookie) SetExpires

func (cookie *Cookie) SetExpires(expires *glib.DateTime)

SetExpires sets cookie's expiration time to expires.

If expires is NULL, cookie will be a session cookie and will expire at the end of the client's session.

(This sets the same property as cookie.SetMaxAge.).

The function takes the following parameters:

  • expires: new expiration time, or NULL.

func (*Cookie) SetHTTPOnly

func (cookie *Cookie) SetHTTPOnly(httpOnly bool)

SetHTTPOnly sets cookie's HttpOnly attribute to http_only.

If TRUE, cookie will be marked as "http only", meaning it should not be exposed to web page scripts or other untrusted code.

The function takes the following parameters:

  • httpOnly: new value for the HttpOnly attribute.

func (*Cookie) SetMaxAge

func (cookie *Cookie) SetMaxAge(maxAge int)

SetMaxAge sets cookie's max age to max_age.

If max_age is -1, the cookie is a session cookie, and will expire at the end of the client's session. Otherwise, it is the number of seconds until the cookie expires. You can use the constants SOUP_COOKIE_MAX_AGE_ONE_HOUR, SOUP_COOKIE_MAX_AGE_ONE_DAY, SOUP_COOKIE_MAX_AGE_ONE_WEEK and SOUP_COOKIE_MAX_AGE_ONE_YEAR (or multiples thereof) to calculate this value. (A value of 0 indicates that the cookie should be considered already-expired.)

This sets the same property as cookie.SetExpires.

The function takes the following parameters:

  • maxAge: new max age.

func (*Cookie) SetName

func (cookie *Cookie) SetName(name string)

SetName sets cookie's name to name.

The function takes the following parameters:

  • name: new name.

func (*Cookie) SetPath

func (cookie *Cookie) SetPath(path string)

SetPath sets cookie's path to path.

The function takes the following parameters:

  • path: new path.

func (*Cookie) SetSameSitePolicy

func (cookie *Cookie) SetSameSitePolicy(policy SameSitePolicy)

SetSameSitePolicy: when used in conjunction with cookiejar.GetCookieListWithSameSiteInfo this sets the policy of when this cookie should be exposed.

The function takes the following parameters:

  • policy: SameSitePolicy.

func (*Cookie) SetSecure

func (cookie *Cookie) SetSecure(secure bool)

SetSecure sets cookie's secure attribute to secure.

If TRUE, cookie will only be transmitted from the client to the server over secure (https) connections.

The function takes the following parameters:

  • secure: new value for the secure attribute.

func (*Cookie) SetValue

func (cookie *Cookie) SetValue(value string)

SetValue sets cookie's value to value.

The function takes the following parameters:

  • value: new value.

func (*Cookie) ToCookieHeader

func (cookie *Cookie) ToCookieHeader() string

ToCookieHeader serializes cookie in the format used by the Cookie header (ie, for returning a cookie from a session to a server).

The function returns the following values:

  • utf8: header.

func (*Cookie) ToSetCookieHeader

func (cookie *Cookie) ToSetCookieHeader() string

ToSetCookieHeader serializes cookie in the format used by the Set-Cookie header.

i.e. for sending a cookie from a server to a client.

The function returns the following values:

  • utf8: header.

func (*Cookie) Value

func (cookie *Cookie) Value() string

Value gets cookie's value.

The function returns the following values:

  • utf8 cookie's value.

type CookieJar

type CookieJar struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

CookieJar: automatic cookie handling for SoupSession.

A CookieJar stores cookies and arrange for them to be sent with the appropriate messages. CookieJar implements sessionfeature, so you can add a cookie jar to a session with session.AddFeature or session.AddFeatureByType.

Note that the base CookieJar class does not support any form of long-term cookie persistence.

func NewCookieJar

func NewCookieJar() *CookieJar

NewCookieJar creates a new CookieJar.

The base CookieJar class does not support persistent storage of cookies; use a subclass for that.

The function returns the following values:

  • cookieJar: new CookieJar.

func (*CookieJar) AcceptPolicy

func (jar *CookieJar) AcceptPolicy() CookieJarAcceptPolicy

AcceptPolicy gets jar's cookiejaracceptpolicy.

The function returns the following values:

  • cookieJarAcceptPolicy set in the jar.

func (*CookieJar) AddCookie

func (jar *CookieJar) AddCookie(cookie *Cookie)

AddCookie adds cookie to jar.

Emits the cookiejar::changed signal if we are modifying an existing cookie or adding a valid new cookie ('valid' means that the cookie's expire date is not in the past).

cookie will be 'stolen' by the jar, so don't free it afterwards.

The function takes the following parameters:

  • cookie: Cookie.

func (*CookieJar) AddCookieFull

func (jar *CookieJar) AddCookieFull(cookie *Cookie, uri, firstParty *glib.URI)

AddCookieFull adds cookie to jar.

Emits the cookiejar::changed signal if we are modifying an existing cookie or adding a valid new cookie ('valid' means that the cookie's expire date is not in the past).

first_party will be used to reject cookies coming from third party resources in case such a security policy is set in the jar.

uri will be used to reject setting or overwriting secure cookies from insecure origins. NULL is treated as secure.

cookie will be 'stolen' by the jar, so don't free it afterwards.

The function takes the following parameters:

  • cookie: Cookie.
  • uri (optional): URI setting the cookie.
  • firstParty (optional): URI for the main document.

func (*CookieJar) AddCookieWithFirstParty

func (jar *CookieJar) AddCookieWithFirstParty(firstParty *glib.URI, cookie *Cookie)

AddCookieWithFirstParty adds cookie to jar.

Emits the cookiejar::changed signal if we are modifying an existing cookie or adding a valid new cookie ('valid' means that the cookie's expire date is not in the past).

first_party will be used to reject cookies coming from third party resources in case such a security policy is set in the jar.

cookie will be 'stolen' by the jar, so don't free it afterwards.

For secure cookies to work properly you may want to use cookiejar.AddCookieFull.

The function takes the following parameters:

  • firstParty: URI for the main document.
  • cookie: Cookie.

func (*CookieJar) AllCookies

func (jar *CookieJar) AllCookies() []*Cookie

AllCookies constructs a glib.List with every cookie inside the jar.

The cookies in the list are a copy of the original, so you have to free them when you are done with them.

The function returns the following values:

  • sList: List with all the cookies in the jar.

func (*CookieJar) ConnectChanged

func (jar *CookieJar) ConnectChanged(f func(oldCookie, newCookie *Cookie)) coreglib.SignalHandle

ConnectChanged is emitted when jar changes.

If a cookie has been added, new_cookie will contain the newly-added cookie and old_cookie will be NULL. If a cookie has been deleted, old_cookie will contain the to-be-deleted cookie and new_cookie will be NULL. If a cookie has been changed, old_cookie will contain its old value, and new_cookie its new value.

func (*CookieJar) CookieList

func (jar *CookieJar) CookieList(uri *glib.URI, forHttp bool) []*Cookie

CookieList retrieves the list of cookies that would be sent with a request to uri as a glib.List of Cookie objects.

If for_http is TRUE, the return value will include cookies marked "HttpOnly" (that is, cookies that the server wishes to keep hidden from client-side scripting operations such as the JavaScript document.cookies property). Since CookieJar sets the Cookie header itself when making the actual HTTP request, you should almost certainly be setting for_http to FALSE if you are calling this.

The function takes the following parameters:

  • uri: #GUri.
  • forHttp: whether or not the return value is being passed directly to an HTTP operation.

The function returns the following values:

  • sList: List with the cookies in the jar that would be sent with a request to uri.

func (*CookieJar) CookieListWithSameSiteInfo

func (jar *CookieJar) CookieListWithSameSiteInfo(uri, topLevel, siteForCookies *glib.URI, forHttp, isSafeMethod, isTopLevelNavigation bool) []*Cookie

CookieListWithSameSiteInfo: this is an extended version of cookiejar.GetCookieList that provides more information required to use SameSite cookies.

See the [SameSite cookies spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00) for more detailed information.

The function takes the following parameters:

  • uri: #GUri.
  • topLevel (optional) for the top level document.
  • siteForCookies (optional) indicating the origin to get cookies for.
  • forHttp: whether or not the return value is being passed directly to an HTTP operation.
  • isSafeMethod: if the HTTP method is safe, as defined by RFC 7231, ignored when for_http is FALSE.
  • isTopLevelNavigation: whether or not the HTTP request is part of top level navigation.

The function returns the following values:

  • sList: List with the cookies in the jar that would be sent with a request to uri.

func (*CookieJar) Cookies

func (jar *CookieJar) Cookies(uri *glib.URI, forHttp bool) string

Cookies retrieves (in Cookie-header form) the list of cookies that would be sent with a request to uri.

If for_http is TRUE, the return value will include cookies marked "HttpOnly" (that is, cookies that the server wishes to keep hidden from client-side scripting operations such as the JavaScript document.cookies property). Since CookieJar sets the Cookie header itself when making the actual HTTP request, you should almost certainly be setting for_http to FALSE if you are calling this.

The function takes the following parameters:

  • uri: #GUri.
  • forHttp: whether or not the return value is being passed directly to an HTTP operation.

The function returns the following values:

  • utf8 (optional): cookies, in string form, or NULL if there are no cookies for uri.

func (*CookieJar) DeleteCookie

func (jar *CookieJar) DeleteCookie(cookie *Cookie)

DeleteCookie deletes cookie from jar.

Emits the cookiejar::changed signal.

The function takes the following parameters:

  • cookie: Cookie.

func (*CookieJar) IsPersistent

func (jar *CookieJar) IsPersistent() bool

IsPersistent gets whether jar stores cookies persistenly.

The function returns the following values:

  • ok: TRUE if jar storage is persistent or FALSE otherwise.

func (*CookieJar) SetAcceptPolicy

func (jar *CookieJar) SetAcceptPolicy(policy CookieJarAcceptPolicy)

SetAcceptPolicy sets policy as the cookie acceptance policy for jar.

The function takes the following parameters:

  • policy: CookieJarAcceptPolicy.

func (*CookieJar) SetCookie

func (jar *CookieJar) SetCookie(uri *glib.URI, cookie string)

SetCookie adds cookie to jar, exactly as though it had appeared in a Set-Cookie header returned from a request to uri.

Keep in mind that if the cookiejaracceptpolicy set is either SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY or SOUP_COOKIE_JAR_ACCEPT_GRANDFATHERED_THIRD_PARTY you'll need to use cookiejar.SetCookieWithFirstParty, otherwise the jar will have no way of knowing if the cookie is being set by a third party or not.

The function takes the following parameters:

  • uri: URI setting the cookie.
  • cookie: stringified cookie to set.

func (*CookieJar) SetCookieWithFirstParty

func (jar *CookieJar) SetCookieWithFirstParty(uri, firstParty *glib.URI, cookie string)

SetCookieWithFirstParty adds cookie to jar, exactly as though it had appeared in a Set-Cookie header returned from a request to uri.

first_party will be used to reject cookies coming from third party resources in case such a security policy is set in the jar.

The function takes the following parameters:

  • uri: URI setting the cookie.
  • firstParty: URI for the main document.
  • cookie: stringified cookie to set.

type CookieJarAcceptPolicy

type CookieJarAcceptPolicy C.gint

CookieJarAcceptPolicy: policy for accepting or rejecting cookies returned in responses.

const (
	// CookieJarAcceptAlways: accept all cookies unconditionally.
	CookieJarAcceptAlways CookieJarAcceptPolicy = iota
	// CookieJarAcceptNever: reject all cookies unconditionally.
	CookieJarAcceptNever
	// CookieJarAcceptNoThirdParty: 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
	// message.SetFirstParty on each outgoing message, setting the 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.
	CookieJarAcceptNoThirdParty
	// CookieJarAcceptGrandfatheredThirdParty: 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
	// message.SetFirstParty on each outgoing Message, setting the 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.
	CookieJarAcceptGrandfatheredThirdParty
)

func (CookieJarAcceptPolicy) String

func (c CookieJarAcceptPolicy) String() string

String returns the name in string for CookieJarAcceptPolicy.

type CookieJarClass

type CookieJarClass struct {
	// contains filtered or unexported fields
}

CookieJarClass: instance of this type is always passed by reference.

func (*CookieJarClass) Padding

func (c *CookieJarClass) Padding() [6]unsafe.Pointer

type CookieJarDB

type CookieJarDB struct {
	CookieJar
	// contains filtered or unexported fields
}

CookieJarDB: database-based Cookie Jar.

CookieJarDB is a cookiejar that reads cookies from and writes them to a sqlite database in the new Mozilla format.

(This is identical to SoupCookieJarSqlite in libsoup-gnome; it has just been moved into libsoup proper, and renamed to avoid conflicting.).

func NewCookieJarDB

func NewCookieJarDB(filename string, readOnly bool) *CookieJarDB

NewCookieJarDB creates a CookieJarDB.

filename will be read in at startup to create an initial set of cookies. If read_only is FALSE, then the non-session cookies will be written to filename when the cookiejar::changed signal is emitted from the jar. (If read_only is TRUE, then the cookie jar will only be used for this session, and changes made to it will be lost when the jar is destroyed.).

The function takes the following parameters:

  • filename to read to/write from, or NULL.
  • readOnly: TRUE if filename is read-only.

The function returns the following values:

  • cookieJarDB: new CookieJar.

type CookieJarDBClass

type CookieJarDBClass struct {
	// contains filtered or unexported fields
}

CookieJarDBClass: instance of this type is always passed by reference.

func (*CookieJarDBClass) ParentClass

func (c *CookieJarDBClass) ParentClass() *CookieJarClass

type CookieJarDBOverrides

type CookieJarDBOverrides struct {
}

CookieJarDBOverrides contains methods that are overridable.

type CookieJarOverrides

type CookieJarOverrides struct {
	// The function takes the following parameters:
	//
	//   - oldCookie
	//   - newCookie
	//
	Changed func(oldCookie, newCookie *Cookie)
	// IsPersistent gets whether jar stores cookies persistenly.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if jar storage is persistent or FALSE otherwise.
	//
	IsPersistent func() bool
	Save         func()
}

CookieJarOverrides contains methods that are overridable.

type CookieJarText

type CookieJarText struct {
	CookieJar
	// contains filtered or unexported fields
}

CookieJarText: text-file-based ("cookies.txt") Cookie Jar

CookieJarText is a cookiejar that reads cookies from and writes them to a text file in format similar to Mozilla's "cookies.txt".

func NewCookieJarText

func NewCookieJarText(filename string, readOnly bool) *CookieJarText

NewCookieJarText creates a CookieJarText.

filename will be read in at startup to create an initial set of cookies. If read_only is FALSE, then the non-session cookies will be written to filename when the cookiejar::changed signal is emitted from the jar. (If read_only is TRUE, then the cookie jar will only be used for this session, and changes made to it will be lost when the jar is destroyed.).

The function takes the following parameters:

  • filename to read to/write from.
  • readOnly: TRUE if filename is read-only.

The function returns the following values:

  • cookieJarText: new CookieJar.

type CookieJarTextClass

type CookieJarTextClass struct {
	// contains filtered or unexported fields
}

CookieJarTextClass: instance of this type is always passed by reference.

func (*CookieJarTextClass) ParentClass

func (c *CookieJarTextClass) ParentClass() *CookieJarClass

type CookieJarTextOverrides

type CookieJarTextOverrides struct {
}

CookieJarTextOverrides contains methods that are overridable.

type DateFormat

type DateFormat C.gint

DateFormat: date formats that 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.

const (
	// DateHTTP: RFC 1123 format, used by the HTTP "Date" header. Eg "Sun,
	// 06 Nov 1994 08:49:37 GMT".
	DateHTTP DateFormat = 1
	// DateCookie: format for the "Expires" timestamp in the Netscape cookie
	// specification. Eg, "Sun, 06-Nov-1994 08:49:37 GMT".
	DateCookie DateFormat = 2
)

func (DateFormat) String

func (d DateFormat) String() string

String returns the name in string for DateFormat.

type Encoding

type Encoding C.gint

Encoding: how a message body is encoded for transport.

const (
	// EncodingUnrecognized: unknown / error.
	EncodingUnrecognized Encoding = iota
	// EncodingNone: no body is present (which is not the same as a 0-length
	// body, and only occurs in certain places).
	EncodingNone
	// EncodingContentLength: content-Length encoding.
	EncodingContentLength
	// EncodingEOF: response body ends when the connection is closed.
	EncodingEOF
	// EncodingChunked: chunked encoding (currently only supported for
	// response).
	EncodingChunked
	// EncodingByteranges multipart/byteranges (Reserved for future use:
	// NOT CURRENTLY IMPLEMENTED).
	EncodingByteranges
)

func (Encoding) String

func (e Encoding) String() string

String returns the name in string for Encoding.

type Expectation

type Expectation C.guint

Expectation represents the parsed value of the "Expect" header.

const (
	// ExpectationUnrecognized: any unrecognized expectation.
	ExpectationUnrecognized Expectation = 0b1
	// ExpectationContinue: "100-continue".
	ExpectationContinue Expectation = 0b10
)

func (Expectation) Has

func (e Expectation) Has(other Expectation) bool

Has returns true if e contains other.

func (Expectation) String

func (e Expectation) String() string

String returns the names in string for Expectation.

type HSTSEnforcer

type HSTSEnforcer struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

HSTSEnforcer: automatic HTTP Strict Transport Security enforcing for session.

A HSTSEnforcer stores HSTS policies and enforces them when required. HSTSEnforcer implements sessionfeature, so you can add an HSTS enforcer to a session with session.AddFeature or session.AddFeatureByType.

HSTSEnforcer keeps track of all the HTTPS destinations that, when connected to, return the Strict-Transport-Security header with valid values. HSTSEnforcer will forget those destinations upon expiry or when the server requests it.

When the session the HSTSEnforcer is attached to queues or restarts a message, the HSTSEnforcer will rewrite the URI to HTTPS if the destination is a known HSTS host and is contacted over an insecure transport protocol (HTTP). Users of HSTSEnforcer are advised to listen to changes in the message:uri property in order to be aware of changes in the message URI.

Note that HSTSEnforcer does not support any form of long-term HSTS policy persistence. See hstsenforcerdb for a persistent enforcer.

func NewHSTSEnforcer

func NewHSTSEnforcer() *HSTSEnforcer

NewHSTSEnforcer creates a new HSTSEnforcer.

The base HSTSEnforcer class does not support persistent storage of HSTS policies, see hstsenforcerdb for that.

The function returns the following values:

  • hstsEnforcer: new HSTSEnforcer.

func (*HSTSEnforcer) ConnectChanged

func (hstsEnforcer *HSTSEnforcer) ConnectChanged(f func(oldPolicy, newPolicy *HSTSPolicy)) coreglib.SignalHandle

ConnectChanged is emitted when hsts_enforcer changes.

If a policy has been added, new_policy will contain the newly-added policy and old_policy will be NULL. If a policy has been deleted, old_policy will contain the to-be-deleted policy and new_policy will be NULL. If a policy has been changed, old_policy will contain its old value, and new_policy its new value.

Note that you shouldn't modify the policies from a callback to this signal.

func (*HSTSEnforcer) Domains

func (hstsEnforcer *HSTSEnforcer) Domains(sessionPolicies bool) []string

Domains gets a list of domains for which there are policies in enforcer.

The function takes the following parameters:

  • sessionPolicies: whether to include session policies.

The function returns the following values:

  • list: newly allocated list of domains. Use glib.List().FreeFull and glib.Free() to free the list.

func (*HSTSEnforcer) HasValidPolicy

func (hstsEnforcer *HSTSEnforcer) HasValidPolicy(domain string) bool

HasValidPolicy gets whether hsts_enforcer has a currently valid policy for domain.

The function takes the following parameters:

  • domain: domain.

The function returns the following values:

  • ok: TRUE if access to domain should happen over HTTPS, false otherwise.

func (*HSTSEnforcer) IsPersistent

func (hstsEnforcer *HSTSEnforcer) IsPersistent() bool

IsPersistent gets whether hsts_enforcer stores policies persistenly.

The function returns the following values:

  • ok: TRUE if hsts_enforcer storage is persistent or FALSE otherwise.

func (*HSTSEnforcer) Policies

func (hstsEnforcer *HSTSEnforcer) Policies(sessionPolicies bool) []*HSTSPolicy

Policies gets a list with the policies in enforcer.

The function takes the following parameters:

  • sessionPolicies: whether to include session policies.

The function returns the following values:

  • list: newly allocated list of policies. Use glib.List().FreeFull and hstspolicy.Free to free the list.

func (*HSTSEnforcer) SetPolicy

func (hstsEnforcer *HSTSEnforcer) SetPolicy(policy *HSTSPolicy)

SetPolicy sets policy to hsts_enforcer.

If policy is expired, any existing HSTS policy for its host will be removed instead. If a policy existed for this host, it will be replaced. Otherwise, the new policy will be inserted. If the policy is a session policy, that is, one created with hstspolicy.NewSessionPolicy, the policy will not expire and will be enforced during the lifetime of hsts_enforcer's session.

The function takes the following parameters:

  • policy of the HSTS host.

func (*HSTSEnforcer) SetSessionPolicy

func (hstsEnforcer *HSTSEnforcer) SetSessionPolicy(domain string, includeSubdomains bool)

SetSessionPolicy sets a session policy for domain.

A session policy is a policy that is permanent to the lifetime of hsts_enforcer's session and doesn't expire.

The function takes the following parameters:

  • domain: policy domain or hostname.
  • includeSubdomains: TRUE if the policy applies on sub domains.

type HSTSEnforcerClass

type HSTSEnforcerClass struct {
	// contains filtered or unexported fields
}

HSTSEnforcerClass class structure for HSTSEnforcer.

An instance of this type is always passed by reference.

type HSTSEnforcerDB

type HSTSEnforcerDB struct {
	HSTSEnforcer
	// contains filtered or unexported fields
}

HSTSEnforcerDB: persistent HTTP Strict Transport Security enforcer.

HSTSEnforcerDB is a hstsenforcer that uses a SQLite database as a backend for persistency.

func NewHSTSEnforcerDB

func NewHSTSEnforcerDB(filename string) *HSTSEnforcerDB

NewHSTSEnforcerDB creates a HSTSEnforcerDB.

filename will be read in during the initialization of a HSTSEnforcerDB, in order to create an initial set of HSTS policies. If the file doesn't exist, a new database will be created and initialized. Changes to the policies during the lifetime of a HSTSEnforcerDB will be written to filename when hstsenforcer::changed is emitted.

The function takes the following parameters:

  • filename of the database to read/write from.

The function returns the following values:

  • hstsEnforcerDB: new HSTSEnforcer.

type HSTSEnforcerDBClass

type HSTSEnforcerDBClass struct {
	// contains filtered or unexported fields
}

HSTSEnforcerDBClass: instance of this type is always passed by reference.

func (*HSTSEnforcerDBClass) ParentClass

func (h *HSTSEnforcerDBClass) ParentClass() *HSTSEnforcerClass

type HSTSEnforcerDBOverrides

type HSTSEnforcerDBOverrides struct {
}

HSTSEnforcerDBOverrides contains methods that are overridable.

type HSTSEnforcerOverrides

type HSTSEnforcerOverrides struct {
	// The function takes the following parameters:
	//
	//   - oldPolicy
	//   - newPolicy
	//
	Changed func(oldPolicy, newPolicy *HSTSPolicy)
	// HasValidPolicy gets whether hsts_enforcer has a currently valid policy
	// for domain.
	//
	// The function takes the following parameters:
	//
	//   - domain: domain.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if access to domain should happen over HTTPS, false
	//     otherwise.
	//
	HasValidPolicy func(domain string) bool
	// IsPersistent gets whether hsts_enforcer stores policies persistenly.
	//
	// The function returns the following values:
	//
	//   - ok: TRUE if hsts_enforcer storage is persistent or FALSE otherwise.
	//
	IsPersistent func() bool
}

HSTSEnforcerOverrides contains methods that are overridable.

type HSTSPolicy

type HSTSPolicy struct {
	// contains filtered or unexported fields
}

HSTSPolicy implements HTTP policies, as described by RFC 6797 (http://tools.ietf.org/html/rfc6797).

domain represents the host that this policy applies to. The domain must be IDNA-canonicalized. hstspolicy.New and related methods will do this for you.

max_age contains the 'max-age' value from the Strict Transport Security header and indicates the time to live of this policy, in seconds.

expires will be non-NULL if the policy has been set by the host and hence has an expiry time. If expires is NULL, it indicates that the policy is a permanent session policy set by the user agent.

If include_subdomains is TRUE, the Strict Transport Security policy must also be enforced on subdomains of domain.

An instance of this type is always passed by reference.

func NewHSTSPolicy

func NewHSTSPolicy(domain string, maxAge uint32, includeSubdomains bool) *HSTSPolicy

NewHSTSPolicy constructs a struct HSTSPolicy.

func NewHSTSPolicyFromResponse

func NewHSTSPolicyFromResponse(msg *Message) *HSTSPolicy

NewHSTSPolicyFromResponse constructs a struct HSTSPolicy.

func NewHSTSPolicyFull

func NewHSTSPolicyFull(domain string, maxAge uint32, expires *glib.DateTime, includeSubdomains bool) *HSTSPolicy

NewHSTSPolicyFull constructs a struct HSTSPolicy.

func NewHSTSPolicySessionPolicy

func NewHSTSPolicySessionPolicy(domain string, includeSubdomains bool) *HSTSPolicy

NewHSTSPolicySessionPolicy constructs a struct HSTSPolicy.

func (*HSTSPolicy) Copy

func (policy *HSTSPolicy) Copy() *HSTSPolicy

Copy copies policy.

The function returns the following values:

  • hstsPolicy: copy of policy.

func (*HSTSPolicy) Domain

func (policy *HSTSPolicy) Domain() string

Domain gets policy's domain.

The function returns the following values:

  • utf8 policy's domain.

func (*HSTSPolicy) Equal

func (policy1 *HSTSPolicy) Equal(policy2 *HSTSPolicy) bool

Equal tests if policy1 and policy2 are equal.

The function takes the following parameters:

  • policy2: HSTSPolicy.

The function returns the following values:

  • ok: whether the policies are equal.

func (*HSTSPolicy) Expires

func (policy *HSTSPolicy) Expires() *glib.DateTime

Expires returns the expiration date for policy.

The function returns the following values:

  • dateTime or NULL if unset.

func (*HSTSPolicy) IncludesSubdomains

func (policy *HSTSPolicy) IncludesSubdomains() bool

IncludesSubdomains gets whether policy include its subdomains.

The function returns the following values:

  • ok: TRUE if policy includes subdomains, FALSE otherwise.

func (*HSTSPolicy) IsExpired

func (policy *HSTSPolicy) IsExpired() bool

IsExpired gets whether policy is expired.

Permanent policies never expire.

The function returns the following values:

  • ok: TRUE if policy is expired, FALSE otherwise.

func (*HSTSPolicy) IsSessionPolicy

func (policy *HSTSPolicy) IsSessionPolicy() bool

IsSessionPolicy gets whether policy is a non-permanent, non-expirable session policy.

See hstspolicy.NewSessionPolicy for details.

The function returns the following values:

  • ok: TRUE if policy is permanent, FALSE otherwise.

func (*HSTSPolicy) MaxAge

func (policy *HSTSPolicy) MaxAge() uint32

MaxAge returns the max age for policy.

The function returns the following values:

  • gulong: max age in seconds.

type HTTPVersion

type HTTPVersion C.gint

HTTPVersion indicates the HTTP protocol version being used.

const (
	// HTTP10: HTTP 1.0 (RFC 1945).
	HTTP10 HTTPVersion = iota
	// HTTP11: HTTP 1.1 (RFC 2616).
	HTTP11
	// HTTP20: HTTP 2.0 (RFC 7540).
	HTTP20
)

func HeadersParseRequest

func HeadersParseRequest(str string, len int, reqHeaders *MessageHeaders) (reqMethod, reqPath string, ver HTTPVersion, guint uint)

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

The function takes the following parameters:

  • str headers (up to, but not including, the trailing blank line).
  • len: length of str.
  • reqHeaders to store the header values in.

The function returns the following values:

  • reqMethod (optional): if non-NULL, will be filled in with the request method.
  • reqPath (optional): if non-NULL, will be filled in with the request path.
  • ver (optional): if non-NULL, will be filled in with the HTTP version.
  • guint: SOUP_STATUS_OK if the headers could be parsed, or an HTTP error to be returned to the client if they could not be.

func HeadersParseResponse

func HeadersParseResponse(str string, len int, headers *MessageHeaders) (HTTPVersion, uint, string, bool)

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

The function takes the following parameters:

  • str headers (up to, but not including, the trailing blank line).
  • len: length of str.
  • headers to store the header values in.

The function returns the following values:

  • ver (optional): if non-NULL, will be filled in with the HTTP version.
  • statusCode (optional): if non-NULL, will be filled in with the status code.
  • reasonPhrase (optional): if non-NULL, will be filled in with the reason phrase.
  • ok success or failure.

func HeadersParseStatusLine

func HeadersParseStatusLine(statusLine string) (HTTPVersion, uint, string, bool)

HeadersParseStatusLine 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".

The function takes the following parameters:

  • statusLine: HTTP Status-Line.

The function returns the following values:

  • ver (optional): if non-NULL, will be filled in with the HTTP version.
  • statusCode (optional): if non-NULL, will be filled in with the status code.
  • reasonPhrase (optional): if non-NULL, will be filled in with the reason phrase.
  • ok: TRUE if status_line was parsed successfully.

func (HTTPVersion) String

func (h HTTPVersion) String() string

String returns the name in string for HTTPVersion.

type Logger

type Logger struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

Logger: debug logging support

Logger watches a session and logs the HTTP traffic that it generates, for debugging purposes. Many applications use an environment variable to determine whether or not to use Logger, and to determine the amount of debugging output.

To use Logger, first create a logger with logger.New, optionally configure it with logger.SetRequestFilter, logger.SetResponseFilter, and logger.SetPrinter, and then attach it to a session (or multiple sessions) with session.AddFeature.

By default, the debugging output is sent to stdout, and looks something like:

> POST /unauth HTTP/1.1
> Soup-Debug-Timestamp: 1200171744
> Soup-Debug: SoupSession 1 (0x612190), SoupMessage 1 (0x617000), GSocket 1 (0x612220)
> Host: localhost
> Content-Type: text/plain
> Connection: close

< HTTP/1.1 201 Created
< Soup-Debug-Timestamp: 1200171744
< Soup-Debug: SoupMessage 1 (0x617000)
< Date: Sun, 12 Jan 2008 21:02:24 GMT
< Content-Length: 0

The Soup-Debug-Timestamp line gives the time (as a time_t) when the request was sent, or the response fully received.

The Soup-Debug line gives further debugging information about the session, message, and gio.Socket involved; the hex numbers are the addresses of the objects in question (which may be useful if you are running in a debugger). The decimal IDs are simply counters that uniquely identify objects across the lifetime of the Logger. In particular, this can be used to identify when multiple messages are sent across the same connection.

Currently, the request half of the message is logged just before the first byte of the request gets written to the network (from the message::starting signal).

The response is logged just after the last byte of the response body is read from the network (from the message::got-body or message::got-informational signal), which means that the message::got-headers signal, and anything triggered off it (such as Message::authenticate) will be emitted *before* the response headers are actually logged.

If the response doesn't happen to trigger the message::got-body nor message::got-informational signals due to, for example, a cancellation before receiving the last byte of the response body, the response will still be logged on the event of the message::finished signal.

func NewLogger

func NewLogger(level LoggerLogLevel) *Logger

NewLogger creates a new Logger with the given debug level.

If you need finer control over what message parts are and aren't logged, use logger.SetRequestFilter and logger.SetResponseFilter.

The function takes the following parameters:

  • level: debug level.

The function returns the following values:

  • logger: new Logger.

func (*Logger) MaxBodySize

func (logger *Logger) MaxBodySize() int

MaxBodySize: get the maximum body size for logger.

The function returns the following values:

  • gint: maximum body size, or -1 if unlimited.

func (*Logger) SetMaxBodySize

func (logger *Logger) SetMaxBodySize(maxBodySize int)

SetMaxBodySize sets the maximum body size for logger (-1 means no limit).

The function takes the following parameters:

  • maxBodySize: maximum body size to log.

func (*Logger) SetPrinter

func (logger *Logger) SetPrinter(printer LoggerPrinter)

SetPrinter sets up an alternate log printing routine, if you don't want the log to go to stdout.

The function takes the following parameters:

  • printer: callback for printing logging output.

func (*Logger) SetRequestFilter

func (logger *Logger) SetRequestFilter(requestFilter LoggerFilter)

SetRequestFilter sets up a filter to determine the log level for a given request.

For each HTTP request logger will invoke request_filter to determine how much (if any) of that request to log. (If you do not set a request filter, logger will just always log requests at the level passed to logger.New.).

The function takes the following parameters:

  • requestFilter: callback for request debugging.

func (*Logger) SetResponseFilter

func (logger *Logger) SetResponseFilter(responseFilter LoggerFilter)

SetResponseFilter sets up a filter to determine the log level for a given response.

For each HTTP response logger will invoke response_filter to determine how much (if any) of that response to log. (If you do not set a response filter, logger will just always log responses at the level passed to logger.New.).

The function takes the following parameters:

  • responseFilter: callback for response debugging.

type LoggerClass

type LoggerClass struct {
	// contains filtered or unexported fields
}

LoggerClass: instance of this type is always passed by reference.

type LoggerFilter

type LoggerFilter func(logger *Logger, msg *Message) (loggerLogLevel LoggerLogLevel)

LoggerFilter: prototype for a logging filter.

The filter callback will be invoked for each request or response, and should analyze it and return a loggerloglevel value indicating how much of the message to log.

type LoggerLogLevel

type LoggerLogLevel C.gint

LoggerLogLevel describes the level of logging output to provide.

const (
	// LoggerLogNone: no logging.
	LoggerLogNone LoggerLogLevel = iota
	// LoggerLogMinimal: log the Request-Line or Status-Line and the Soup-Debug
	// pseudo-headers.
	LoggerLogMinimal
	// LoggerLogHeaders: log the full request/response headers.
	LoggerLogHeaders
	// LoggerLogBody: log the full headers and request/response bodies.
	LoggerLogBody
)

func (LoggerLogLevel) String

func (l LoggerLogLevel) String() string

String returns the name in string for LoggerLogLevel.

type LoggerOverrides

type LoggerOverrides struct {
}

LoggerOverrides contains methods that are overridable.

type LoggerPrinter

type LoggerPrinter func(logger *Logger, level LoggerLogLevel, direction byte, data string)

LoggerPrinter: prototype for a custom printing callback.

level indicates what kind of information is being printed. Eg, it will be SOUP_LOGGER_LOG_HEADERS if data is header data.

direction is either '<', '>', or ' ', and data is the single line to print; the printer is expected to add a terminating newline.

To get the effect of the default printer, you would do:

printf ("c s\n", direction, data);.

type MemoryUse

type MemoryUse C.gint

MemoryUse: lifetime of the memory being passed.

const (
	// MemoryStatic: 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.
	MemoryStatic MemoryUse = iota
	// MemoryTake: caller has allocated the memory and libsoup will assume
	// ownership of it and free it with glib.Free().
	MemoryTake
	// MemoryCopy: passed-in data belongs to the caller and libsoup will copy it
	// into new memory leaving the caller free to reuse the original memory.
	MemoryCopy
)

func (MemoryUse) String

func (m MemoryUse) String() string

String returns the name in string for MemoryUse.

type Message

type Message struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

Message represents an HTTP message being sent or received.

A Message represents an HTTP message that is being sent or received.

You would create a Message with message.New or message.NewFromURI, set up its fields appropriately, and send it.

message:status-code will normally be a status value, eg, SOUP_STATUS_OK, though of course it might actually be an unknown status code. message:reason-phrase is the actual text returned from the server, which may or may not correspond to the "standard" description of status_code. At any rate, it is almost certainly not localized, and not very descriptive even if it is in the user's language; you should not use message:reason-phrase in user-visible messages. Rather, you should look at message:status-code, and determine an end-user-appropriate message based on that and on what you were trying to do.

Note that libsoup's terminology here does not quite match the HTTP specification: in RFC 2616, an "HTTP-message" is *either* a Request, *or* a Response. In libsoup, a Message combines both the request and the response.

func NewMessage

func NewMessage(method, uriString string) *Message

NewMessage creates a new empty Message, which will connect to uri.

The function takes the following parameters:

  • method: HTTP method for the created request.
  • uriString: destination endpoint (as a string).

The function returns the following values:

  • message (optional): new Message (or NULL if uri could not be parsed).

func NewMessageFromEncodedForm

func NewMessageFromEncodedForm(method, uriString, encodedForm string) *Message

NewMessageFromEncodedForm creates a new Message and sets it up to send the given encoded_form to uri via method. If method is "GET", it will include the form data into uri's query field, and if method is "POST" or "PUT", it will be set as request body.

This function takes the ownership of encoded_form, that will be released with glib.Free() when no longer in use. See also form_encode, form_encode_hash and form_encode_datalist.

The function takes the following parameters:

  • method: HTTP method for the created request (GET, POST or PUT).
  • uriString: destination endpoint (as a string).
  • encodedForm: encoded form.

The function returns the following values:

  • message (optional): new Message, or NULL if uri_string could not be parsed or method is not "GET, "POST" or "PUT".

func NewMessageFromMultipart

func NewMessageFromMultipart(uriString string, multipart *Multipart) *Message

NewMessageFromMultipart creates a new Message and sets it up to send multipart to uri_string via POST.

The function takes the following parameters:

  • uriString: destination endpoint.
  • multipart: Multipart.

The function returns the following values:

  • message (optional): new Message, or NULL if uri_string could not be parsed.

func NewMessageFromURI

func NewMessageFromURI(method string, uri *glib.URI) *Message

NewMessageFromURI creates a new empty Message, which will connect to uri.

The function takes the following parameters:

  • method: HTTP method for the created request.
  • uri: destination endpoint.

The function returns the following values:

  • message: new Message.

func NewMessageOptionsPing

func NewMessageOptionsPing(baseUri *glib.URI) *Message

NewMessageOptionsPing creates a new Message to send OPTIONS * to a server. The path of base_uri will be ignored.

The function takes the following parameters:

  • baseUri: destination endpoint.

The function returns the following values:

  • message: new Message.

func (*Message) AddFlags

func (msg *Message) AddFlags(flags MessageFlags)

AddFlags adds flags to the set of msg's flags.

The function takes the following parameters:

  • flags: set of MessageFlags values.

func (*Message) ConnectAcceptCertificate

func (msg *Message) ConnectAcceptCertificate(f func(tlsPeerCertificate gio.TLSCertificater, tlsPeerErrors gio.TLSCertificateFlags) (ok bool)) coreglib.SignalHandle

ConnectAcceptCertificate is emitted during the msg's connection TLS handshake after an unacceptable TLS certificate has been received.

You can return TRUE to accept tls_certificate despite tls_errors.

func (*Message) ConnectAuthenticate

func (msg *Message) ConnectAuthenticate(f func(auth Auther, retrying bool) (ok bool)) coreglib.SignalHandle

ConnectAuthenticate is emitted when the message requires authentication.

If credentials are available call auth.Authenticate on auth. If these credentials fail, the signal will be emitted again, with retrying set to TRUE, which will continue until you return without calling auth.Authenticate on auth.

Note that this may be emitted before msg's body has been fully read.

You can authenticate auth asynchronously by calling gobject.Object.Ref() on auth and returning TRUE. The operation will complete once either auth.Authenticate or auth.Cancel are called.

func (*Message) ConnectContentSniffed

func (msg *Message) ConnectContentSniffed(f func(typ string, params map[string]string)) coreglib.SignalHandle

ConnectContentSniffed: this signal is emitted after message::got-headers.

If content sniffing is disabled, or no content sniffing will be performed, due to the sniffer deciding to trust the Content-Type sent by the server, this signal is emitted immediately after message::got-headers, and type is NULL.

func (*Message) ConnectFinished

func (msg *Message) ConnectFinished(f func()) coreglib.SignalHandle

ConnectFinished is emitted when all HTTP processing is finished for a message.

(After message::got_body).

func (*Message) ConnectGotBody

func (msg *Message) ConnectGotBody(f func()) coreglib.SignalHandle

ConnectGotBody is emitted after receiving the complete message response body.

func (*Message) ConnectGotBodyData

func (msg *Message) ConnectGotBodyData(f func(chunkSize uint)) coreglib.SignalHandle

ConnectGotBodyData is emitted after reading a portion of the message body from the network.

func (*Message) ConnectGotHeaders

func (msg *Message) ConnectGotHeaders(f func()) coreglib.SignalHandle

ConnectGotHeaders is emitted after receiving the Status-Line and response headers.

See also message.AddHeaderHandler and message.AddStatusCodeHandler, which can be used to connect to a subset of emissions of this signal.

If you cancel or requeue msg while processing this signal, then the current HTTP I/O will be stopped after this signal emission finished, and msg's connection will be closed. (If you need to requeue a message--eg, after handling authentication or redirection--it is usually better to requeue it from a message::got-body handler rather than a message::got_headers handler, so that the existing HTTP connection can be reused.).

func (*Message) ConnectGotInformational

func (msg *Message) ConnectGotInformational(f func()) coreglib.SignalHandle

ConnectGotInformational is emitted after receiving a 1xx (Informational) response for a (client-side) message.

The response_headers will be filled in with the headers associated with the informational response; however, those header values will be erased after this signal is done.

If you cancel or requeue msg while processing this signal, then the current HTTP I/O will be stopped after this signal emission finished, and msg's connection will be closed.

func (*Message) ConnectHstsEnforced

func (msg *Message) ConnectHstsEnforced(f func()) coreglib.SignalHandle

ConnectHstsEnforced is emitted when hstsenforcer has upgraded the protocol for msg to HTTPS as a result of matching its domain with a HSTS policy.

func (*Message) ConnectNetworkEvent

func (msg *Message) ConnectNetworkEvent(f func(event gio.SocketClientEvent, connection gio.IOStreamer)) coreglib.SignalHandle

ConnectNetworkEvent is emitted to indicate that some network-related event related to msg has occurred.

This essentially proxies the gio.SocketClient::event signal, but only for events that occur while msg "owns" the connection; if msg is sent on an existing persistent connection, then this signal will not be emitted. (If you want to force the message to be sent on a new connection, set the SOUP_MESSAGE_NEW_CONNECTION flag on it.)

See gio.SocketClient::event for more information on what the different values of event correspond to, and what connection will be in each case.

func (*Message) ConnectRequestCertificate

func (msg *Message) ConnectRequestCertificate(f func(tlsConnection gio.TLSClientConnectioner) (ok bool)) coreglib.SignalHandle

ConnectRequestCertificate is emitted during the msg's connection TLS handshake when tls_connection requests a certificate from the client.

You can set the client certificate by calling message.SetTLSClientCertificate and returning TRUE. It's possible to handle the request asynchornously by returning TRUE and call message.SetTLSClientCertificate later once the certificate is available. Note that this signal is not emitted if session:tls-interaction was set, or if message.SetTLSClientCertificate was called before the connection TLS handshake started.

func (*Message) ConnectRequestCertificatePassword

func (msg *Message) ConnectRequestCertificatePassword(f func(tlsPassword *gio.TLSPassword) (ok bool)) coreglib.SignalHandle

ConnectRequestCertificatePassword is emitted during the msg's connection TLS handshake when tls_connection requests a certificate password from the client.

You can set the certificate password on password, then call message.TLSClientCertificatePasswordRequestComplete and return TRUE to handle the signal synchronously. It's possible to handle the request asynchornously by calling gobject.Object.Ref() on password, then returning TRUE and call message.TLSClientCertificatePasswordRequestComplete later after setting the password on password. Note that this signal is not emitted if session:tls-interaction was set.

func (*Message) ConnectRestarted

func (msg *Message) ConnectRestarted(f func()) coreglib.SignalHandle

ConnectRestarted is emitted when a request that was already sent once is now being sent again.

e.g. because the first attempt received a redirection response, or because we needed to use authentication.

func (*Message) ConnectStarting

func (msg *Message) ConnectStarting(f func()) coreglib.SignalHandle

ConnectStarting is emitted just before a message is sent.

func (*Message) ConnectWroteBody

func (msg *Message) ConnectWroteBody(f func()) coreglib.SignalHandle

ConnectWroteBody is emitted immediately after writing the complete body for a message.

func (*Message) ConnectWroteBodyData

func (msg *Message) ConnectWroteBodyData(f func(chunkSize uint)) coreglib.SignalHandle

ConnectWroteBodyData is emitted immediately after writing a portion of the message body to the network.

func (*Message) ConnectWroteHeaders

func (msg *Message) ConnectWroteHeaders(f func()) coreglib.SignalHandle

ConnectWroteHeaders is emitted immediately after writing the request headers for a message.

func (*Message) ConnectionID

func (msg *Message) ConnectionID() uint64

ConnectionID returns the unique idenfier for the last connection used.

This may be 0 if it was a cached resource or it has not gotten a connection yet.

The function returns the following values:

  • guint64: id or 0 if no connection.

func (*Message) DisableFeature

func (msg *Message) DisableFeature(featureType coreglib.Type)

DisableFeature disables the actions of sessionfeatures with the given feature_type (or a subclass of that type) on msg.

msg is processed as though the feature(s) hadn't been added to the session. Eg, passing UP_TYPE_CONTENT_SNIFFER for feature_type will disable Content-Type sniffing on the message.

You must call this before queueing msg on a session; calling it on a message that has already been queued is undefined. In particular, you cannot call this on a message that is being requeued after a redirect or authentication.

The function takes the following parameters:

  • featureType of a SessionFeature.

func (*Message) FirstParty

func (msg *Message) FirstParty() *glib.URI

FirstParty gets msg's first-party glib.URI.

The function returns the following values:

  • uri msg's first party #GUri.

func (*Message) Flags

func (msg *Message) Flags() MessageFlags

Flags gets the flags on msg.

The function returns the following values:

  • messageFlags: flags.

func (*Message) ForceHTTP1

func (msg *Message) ForceHTTP1() bool

ForceHTTP1 returns whether HTTP/1 version is currently demanded for the msg send.

The function returns the following values:

  • ok: TRUE, when HTTP/1 is demanded, FALSE otherwise.

func (*Message) HTTPVersion

func (msg *Message) HTTPVersion() HTTPVersion

HTTPVersion gets the HTTP version of msg.

This is the minimum of the version from the request and the version from the response.

The function returns the following values:

  • httpVersion: HTTP version.

func (*Message) IsFeatureDisabled

func (msg *Message) IsFeatureDisabled(featureType coreglib.Type) bool

IsFeatureDisabled: get whether sessionfeatures of the given feature_type (or a subclass of that type) are disabled on msg.

See message.DisableFeature.

The function takes the following parameters:

  • featureType of a SessionFeature.

The function returns the following values:

  • ok: TRUE if feature is disabled, or FALSE otherwise.

func (*Message) IsKeepalive

func (msg *Message) IsKeepalive() bool

IsKeepalive determines whether or not msg's connection can be kept alive for further requests after processing msg.

The result is based on the HTTP version, Connection header, etc.

The function returns the following values:

  • ok: TRUE or FALSE.

func (*Message) IsOptionsPing

func (msg *Message) IsOptionsPing() bool

IsOptionsPing gets whether msg is intended to be used to send OPTIONS * to a server.

The function returns the following values:

  • ok: TRUE if the message is options ping, or FALSE otherwise.

func (*Message) IsTopLevelNavigation

func (msg *Message) IsTopLevelNavigation() bool

IsTopLevelNavigation returns if this message is set as a top level navigation.

Used for same-site policy checks.

The function returns the following values:

  • ok: whether the current request is a top-level navitation.

func (*Message) Method

func (msg *Message) Method() string

Method returns the method of this message.

The function returns the following values:

  • utf8: method such as SOUP_METHOD_GET.

func (*Message) Metrics

func (msg *Message) Metrics() *MessageMetrics

Metrics: get the messagemetrics of msg.

If the flag SOUP_MESSAGE_COLLECT_METRICS is not enabled for msg this will return NULL.

The function returns the following values:

  • messageMetrics (optional): MessageMetrics.

func (*Message) Priority

func (msg *Message) Priority() MessagePriority

Priority retrieves the messagepriority.

If not set this value defaults to UP_MESSAGE_PRIORITY_NORMAL.

The function returns the following values:

  • messagePriority: priority of the message.

func (*Message) QueryFlags

func (msg *Message) QueryFlags(flags MessageFlags) bool

QueryFlags queries if flags are present in the set of msg's flags.

The function takes the following parameters:

  • flags: set of MessageFlags values.

The function returns the following values:

  • ok: TRUE if flags are enabled in msg.

func (*Message) ReasonPhrase

func (msg *Message) ReasonPhrase() string

ReasonPhrase returns the reason phrase for the status of this message.

The function returns the following values:

  • utf8 (optional): phrase.

func (*Message) RemoteAddress

func (msg *Message) RemoteAddress() gio.SocketAddresser

RemoteAddress: get the remote gio.SocketAddress of the connection associated with the message.

The returned address can be NULL if the connection hasn't been established yet, or the resource was loaded from the disk cache. In case of proxy connections, the remote address returned is a gio.ProxyAddress. If session:remote-connectable is set the returned address id for the connection to the session's remote connectable.

The function returns the following values:

  • socketAddress (optional) or NULL if the connection hasn't been established.

func (*Message) RemoveFlags

func (msg *Message) RemoveFlags(flags MessageFlags)

RemoveFlags removes flags from the set of msg's flags.

The function takes the following parameters:

  • flags: set of MessageFlags values.

func (*Message) RequestHeaders

func (msg *Message) RequestHeaders() *MessageHeaders

RequestHeaders returns the headers sent with the request.

The function returns the following values:

  • messageHeaders: MessageHeaders.

func (*Message) ResponseHeaders

func (msg *Message) ResponseHeaders() *MessageHeaders

ResponseHeaders returns the headers recieved with the response.

The function returns the following values:

  • messageHeaders: MessageHeaders.

func (*Message) SetFirstParty

func (msg *Message) SetFirstParty(firstParty *glib.URI)

SetFirstParty sets first_party as the main document #GUri for msg.

For details of when and how this is used refer to the documentation for cookiejaracceptpolicy.

The function takes the following parameters:

  • firstParty for the msg's first party.

func (*Message) SetFlags

func (msg *Message) SetFlags(flags MessageFlags)

SetFlags sets the specified flags on msg.

The function takes the following parameters:

  • flags: set of MessageFlags values.

func (*Message) SetForceHTTP1

func (msg *Message) SetForceHTTP1(value bool)

SetForceHTTP1 sets whether HTTP/1 version should be used when sending this message. Some connections can still override it, if needed.

Note the value is unset after the message send is finished.

The function takes the following parameters:

  • value to set.

func (*Message) SetIsOptionsPing

func (msg *Message) SetIsOptionsPing(isOptionsPing bool)

SetIsOptionsPing: set whether msg is intended to be used to send OPTIONS * to a server.

When set to TRUE, the path of message:uri will be ignored and message:method set to SOUP_METHOD_OPTIONS.

The function takes the following parameters:

  • isOptionsPing: value to set.

func (*Message) SetIsTopLevelNavigation

func (msg *Message) SetIsTopLevelNavigation(isTopLevelNavigation bool)

SetIsTopLevelNavigation sets whether the current request is a top-level navitation.

See the same-site spec (https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00) for more information.

The function takes the following parameters:

  • isTopLevelNavigation: if TRUE indicate the current request is a top-level navigation.

func (*Message) SetMethod

func (msg *Message) SetMethod(method string)

SetMethod: set msg's HTTP method to method.

The function takes the following parameters:

  • method: value to set.

func (*Message) SetPriority

func (msg *Message) SetPriority(priority MessagePriority)

SetPriority sets the priority of a message.

Note that this won't have any effect unless used before the message is added to the session's message processing queue.

The message will be placed just before any other previously added message with lower priority (messages with the same priority are processed on a FIFO basis).

Setting priorities does not currently work with synchronous messages because in the synchronous/blocking case, priority ends up being determined semi-randomly by thread scheduling.

The function takes the following parameters:

  • priority: MessagePriority.

func (*Message) SetRequestBody

func (msg *Message) SetRequestBody(contentType string, stream gio.InputStreamer, contentLength int)

SetRequestBody: set the request body of a Message.

If content_type is NULL and stream is not NULL the Content-Type header will not be changed if present. The request body needs to be set again in case msg is restarted (in case of redirection or authentication).

The function takes the following parameters:

  • contentType (optional): MIME Content-Type of the body, or NULL if unknown.
  • stream (optional) to read the request body from.
  • contentLength: byte length of stream or -1 if unknown.

func (*Message) SetRequestBodyFromBytes

func (msg *Message) SetRequestBodyFromBytes(contentType string, bytes *glib.Bytes)

SetRequestBodyFromBytes: set the request body of a Message from glib.Bytes.

If content_type is NULL and bytes is not NULL the Content-Type header will not be changed if present. The request body needs to be set again in case msg is restarted (in case of redirection or authentication).

The function takes the following parameters:

  • contentType (optional): MIME Content-Type of the body, or NULL if unknown.
  • bytes (optional) with the request body data.

func (*Message) SetSiteForCookies

func (msg *Message) SetSiteForCookies(siteForCookies *glib.URI)

SetSiteForCookies sets site_for_cookies as the policy URL for same-site cookies for msg.

It is either the URL of the top-level document or NULL depending on whether the registrable domain of this document's URL matches the registrable domain of its parent's/opener's URL. For the top-level document it is set to the document's URL.

See the same-site spec (https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00) for more information.

The function takes the following parameters:

  • siteForCookies (optional) for the msg's site for cookies.

func (*Message) SetTLSClientCertificate

func (msg *Message) SetTLSClientCertificate(certificate gio.TLSCertificater)

SetTLSClientCertificate sets the certificate to be used by msg's connection when a client certificate is requested during the TLS handshake.

You can call this as a response to message::request-certificate signal, or before the connection is started. If certificate is NULL the handshake will continue without providing a GTlsCertificate. Note that the gio.TLSCertificate set by this function will be ignored if session:tls-interaction is not NULL.

The function takes the following parameters:

  • certificate (optional) to set, or NULL.

func (*Message) SetURI

func (msg *Message) SetURI(uri *glib.URI)

SetURI sets msg's URI to uri.

If msg has already been sent and you want to re-send it with the new URI, you need to send it again.

The function takes the following parameters:

  • uri: new #GUri.

func (*Message) SiteForCookies

func (msg *Message) SiteForCookies() *glib.URI

SiteForCookies gets msg's site for cookies #GUri.

The function returns the following values:

  • uri msg's site for cookies #GUri.

func (*Message) Status

func (msg *Message) Status() Status

Status returns the set status of this message.

The function returns the following values:

  • status: Status.

func (*Message) TLSCiphersuiteName

func (msg *Message) TLSCiphersuiteName() string

TLSCiphersuiteName gets the name of the TLS ciphersuite negotiated for msg's connection.

The function returns the following values:

  • utf8: name of the TLS ciphersuite, or NULL if msg's connection is not SSL.

func (*Message) TLSClientCertificatePasswordRequestComplete

func (msg *Message) TLSClientCertificatePasswordRequestComplete()

TLSClientCertificatePasswordRequestComplete completes a certificate password request.

You must call this as a response to message::request-certificate-password signal, to notify msg that the gio.TLSPassword has already been updated.

func (*Message) TLSPeerCertificate

func (msg *Message) TLSPeerCertificate() gio.TLSCertificater

TLSPeerCertificate gets the peer's gio.TLSCertificate associated with msg's connection.

Note that this is not set yet during the emission of message::accept-certificate signal.

The function returns the following values:

  • tlsCertificate (optional) msg's TLS peer certificate, or NULL if msg's connection is not SSL.

func (*Message) TLSPeerCertificateErrors

func (msg *Message) TLSPeerCertificateErrors() gio.TLSCertificateFlags

TLSPeerCertificateErrors gets the errors associated with validating msg's TLS peer certificate. Note that this is not set yet during the emission of message::accept-certificate signal.

The function returns the following values:

  • tlsCertificateFlags with msg's TLS peer certificate errors.

func (*Message) URI

func (msg *Message) URI() *glib.URI

URI gets msg's URI.

The function returns the following values:

  • uri: URI msg is targeted for.

type MessageBody

type MessageBody struct {
	// contains filtered or unexported fields
}

MessageBody represents the request or response body of a message.

Note that while length always reflects the full length of the message body, data is normally NULL, and will only be filled in after messagebody.Flatten is called. For client-side messages, this automatically happens for the response body after it has been fully read. Likewise, for server-side messages, the request body is automatically filled in after being read.

As an added bonus, when data is filled in, it is always terminated with a \0 byte (which is not reflected in length).

An instance of this type is always passed by reference.

func NewMessageBody

func NewMessageBody() *MessageBody

NewMessageBody constructs a struct MessageBody.

func (*MessageBody) Accumulate

func (body *MessageBody) Accumulate() bool

Accumulate gets the accumulate flag on body.

See [methodMessageBody.set_accumulate. for details.

The function returns the following values:

  • ok: accumulate flag for body.

func (*MessageBody) Append

func (body *MessageBody) Append(data []byte)

Append appends length bytes from data to body.

This function is exactly equivalent to messagebody.Append with SOUP_MEMORY_TAKE as second argument; it exists mainly for convenience and simplifying language bindings.

The function takes the following parameters:

  • data to append.

func (*MessageBody) AppendBytes

func (body *MessageBody) AppendBytes(buffer *glib.Bytes)

AppendBytes appends the data from buffer to body.

The function takes the following parameters:

  • buffer: #GBytes.

func (*MessageBody) Chunk

func (body *MessageBody) Chunk(offset int64) *glib.Bytes

Chunk gets a glib.Bytes containing data from body starting at offset.

The size of the returned chunk is unspecified. You can iterate through the entire body by first calling messagebody.GetChunk with an offset of 0, and then on each successive call, increment the offset by the length of the previously-returned chunk.

If offset is greater than or equal to the total length of body, then the return value depends on whether or not messagebody.Complete has been called or not; if it has, then messagebody.GetChunk will return a 0-length chunk (indicating the end of body). If it has not, then messagebody.GetChunk will return NULL (indicating that body may still potentially have more data, but that data is not currently available).

The function takes the following parameters:

  • offset: offset.

The function returns the following values:

  • bytes (optional): #GBytes.

func (*MessageBody) Complete

func (body *MessageBody) Complete()

Complete tags body as being complete.

Call this when using chunked encoding after you have appended the last chunk.

func (*MessageBody) Flatten

func (body *MessageBody) Flatten() *glib.Bytes

Flatten fills in body's data field with a buffer containing all of the data in body.

Adds an additional \0 byte not counted by body's length field.

The function returns the following values:

  • bytes containing the same data as body. (You must glib.Bytes.Unref() this if you do not want it.).

func (*MessageBody) GotChunk

func (body *MessageBody) GotChunk(chunk *glib.Bytes)

GotChunk handles the MessageBody part of receiving a chunk of data from the network.

Normally this means appending chunk to body, exactly as with messagebody.AppendBytes, but if you have set body's accumulate flag to FALSE, then that will not happen.

This is a low-level method which you should not normally need to use.

The function takes the following parameters:

  • chunk received from the network.

func (*MessageBody) SetAccumulate

func (body *MessageBody) SetAccumulate(accumulate bool)

SetAccumulate sets or clears the accumulate flag on body.

(The default value is TRUE.) If set to FALSE, body's data field will not be filled in after the body is fully sent/received, and the chunks that make up body may be discarded when they are no longer needed.

If you set the flag to FALSE on the message request_body of a client-side message, it will block the accumulation of chunks into body's data field, but it will not normally cause the chunks to be discarded after being written like in the server-side message response_body case, because the request body needs to be kept around in case the request needs to be sent a second time due to redirection or authentication.

The function takes the following parameters:

  • accumulate: whether or not to accumulate body chunks in body.

func (*MessageBody) Truncate

func (body *MessageBody) Truncate()

Truncate deletes all of the data in body.

func (*MessageBody) WroteChunk

func (body *MessageBody) WroteChunk(chunk *glib.Bytes)

WroteChunk handles the MessageBody part of writing a chunk of data to the network.

Normally this is a no-op, but if you have set body's accumulate flag to FALSE, then this will cause chunk to be discarded to free up memory.

This is a low-level method which you should not need to use, and there are further restrictions on its proper use which are not documented here.

The function takes the following parameters:

  • chunk returned from messagebody.GetChunk.

type MessageClass

type MessageClass struct {
	// contains filtered or unexported fields
}

MessageClass: instance of this type is always passed by reference.

type MessageFlags

type MessageFlags C.guint

MessageFlags various flags that can be set on a Message to alter its behavior.

const (
	// MessageNoRedirect: session should not follow redirect (3xx) responses
	// received by this message.
	MessageNoRedirect MessageFlags = 0b10
	// MessageNewConnection requests that the message should be sent on a
	// newly-created connection, not reusing an existing persistent connection.
	// Note that messages with non-idempotent message:methods behave this way by
	// default, unless UP_MESSAGE_IDEMPOTENT is set.
	MessageNewConnection MessageFlags = 0b100
	// MessageIdempotent: message is considered idempotent, regardless its
	// message:method, and allows reuse of existing idle connections, instead of
	// always requiring a new one, unless UP_MESSAGE_NEW_CONNECTION is set.
	MessageIdempotent MessageFlags = 0b1000
	// MessageDoNotUseAuthCache: 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 message::authenticate signal
	// will be emitted, if you want to disable authentication for a message use
	// message.DisableFeature passing UP_TYPE_AUTH_MANAGER instead.
	MessageDoNotUseAuthCache MessageFlags = 0b10000
	// MessageCollectMetrics metrics will be collected for this message.
	MessageCollectMetrics MessageFlags = 0b100000
)

func (MessageFlags) Has

func (m MessageFlags) Has(other MessageFlags) bool

Has returns true if m contains other.

func (MessageFlags) String

func (m MessageFlags) String() string

String returns the names in string for MessageFlags.

type MessageHeaders

type MessageHeaders struct {
	// contains filtered or unexported fields
}

MessageHeaders: HTTP message headers associated with a request or response.

An instance of this type is always passed by reference.

func NewMessageHeaders

func NewMessageHeaders(typ MessageHeadersType) *MessageHeaders

NewMessageHeaders constructs a struct MessageHeaders.

func (*MessageHeaders) Append

func (hdrs *MessageHeaders) Append(name string, value string)

Append appends a new header with name name and value value to hdrs.

(If there is an existing header with name name, then this creates a second one, which is only allowed for list-valued headers; see also messageheaders.Replace.)

The caller is expected to make sure that name and value are syntactically correct.

The function takes the following parameters:

  • name: header name to add.
  • value: new value of name.

func (*MessageHeaders) CleanConnectionHeaders

func (hdrs *MessageHeaders) CleanConnectionHeaders()

CleanConnectionHeaders removes all the headers listed in the Connection header.

func (*MessageHeaders) Clear

func (hdrs *MessageHeaders) Clear()

Clear clears hdrs.

func (*MessageHeaders) ContentDisposition

func (hdrs *MessageHeaders) ContentDisposition() (string, map[string]string, bool)

ContentDisposition looks up the "Content-Disposition" header in hdrs, parses it, and returns its value in *disposition and *params.

params can be NULL if you are only interested in the disposition-type.

In HTTP, the most common use of this header is to set a disposition-type of "attachment", to suggest to the browser that a response should be saved to disk rather than displayed in the browser. If params contains a "filename" parameter, this is a suggestion of a filename to use. (If the parameter value in the header contains an absolute or relative path, libsoup will truncate it down to just the final path component, so you do not need to test this yourself.)

Content-Disposition is also used in "multipart/form-data", however this is handled automatically by multipart and the associated form methods.

The function returns the following values:

  • disposition: return location for the disposition-type, or NULL.
  • params: return location for the Content-Disposition parameters, or NULL.
  • ok: TRUE if hdrs contains a "Content-Disposition" header, FALSE if not (in which case *disposition and *params will be unchanged).

func (*MessageHeaders) ContentLength

func (hdrs *MessageHeaders) ContentLength() int64

ContentLength gets the message body length that hdrs declare.

This will only be non-0 if messageheaders.GetEncoding returns SOUP_ENCODING_CONTENT_LENGTH.

The function returns the following values:

  • gint64: message body length declared by hdrs.

func (*MessageHeaders) ContentRange

func (hdrs *MessageHeaders) ContentRange() (start int64, end int64, totalLength int64, ok bool)

ContentRange parses hdrs's Content-Range header and returns it in start, end, and total_length. If the total length field in the header was specified as "*", then total_length will be set to -1.

The function returns the following values:

  • start: return value for the start of the range.
  • end: return value for the end of the range.
  • totalLength (optional): return value for the total length of the resource, or NULL if you don't care.
  • ok: TRUE if hdrs contained a "Content-Range" header containing a byte range which could be parsed, FALSE otherwise.

func (*MessageHeaders) ContentType

func (hdrs *MessageHeaders) ContentType() (map[string]string, string)

ContentType looks up the "Content-Type" header in hdrs, parses it, and returns its value in *content_type and *params.

params can be NULL if you are only interested in the content type itself.

The function returns the following values:

  • params (optional): return location for the Content-Type parameters (eg, "charset"), or NULL.
  • utf8 (optional): string with the value of the "Content-Type" header or NULL if hdrs does not contain that header or it cannot be parsed (in which case *params will be unchanged).

func (*MessageHeaders) Encoding

func (hdrs *MessageHeaders) Encoding() Encoding

Encoding gets the message body encoding that hdrs declare.

This may not always correspond to the encoding used on the wire; eg, a HEAD response may declare a Content-Length or Transfer-Encoding, but it will never actually include a body.

The function returns the following values:

  • encoding declared by hdrs.

func (*MessageHeaders) Expectations

func (hdrs *MessageHeaders) Expectations() Expectation

Expectations gets the expectations declared by hdrs's "Expect" header.

Currently this will either be SOUP_EXPECTATION_CONTINUE or SOUP_EXPECTATION_UNRECOGNIZED.

The function returns the following values:

  • expectation contents of hdrs's "Expect" header.

func (*MessageHeaders) ForEach

func (hdrs *MessageHeaders) ForEach(fn MessageHeadersForEachFunc)

ForEach calls func once for each header value in hdrs.

Beware that unlike messageheaders.GetList, this processes the headers in exactly the way they were added, rather than concatenating multiple same-named headers into a single value. (This is intentional; it ensures that if you call messageheaders.Append multiple times with the same name, then the I/O code will output multiple copies of the header when sending the message to the remote implementation, which may be required for interoperability in some cases.)

You may not modify the headers from func.

The function takes the following parameters:

  • fn: callback function to run for each header.

func (*MessageHeaders) FreeRanges

func (hdrs *MessageHeaders) FreeRanges(ranges *Range)

FreeRanges frees the array of ranges returned from messageheaders.GetRanges.

The function takes the following parameters:

  • ranges: array of Range.

func (*MessageHeaders) HeaderContains

func (hdrs *MessageHeaders) HeaderContains(name string, token string) bool

HeaderContains checks whether the list-valued header name is present in hdrs, and contains a case-insensitive match for token.

(If name is present in hdrs, then this is equivalent to calling header_contains on its value.).

The function takes the following parameters:

  • name: header name.
  • token to look for.

The function returns the following values:

  • ok: TRUE if the header is present and contains token, FALSE otherwise.

func (*MessageHeaders) HeaderEquals

func (hdrs *MessageHeaders) HeaderEquals(name string, value string) bool

HeaderEquals checks whether the header name is present in hdrs and is (case-insensitively) equal to value.

The function takes the following parameters:

  • name: header name.
  • value: expected value.

The function returns the following values:

  • ok: TRUE if the header is present and its value is value, FALSE otherwise.

func (*MessageHeaders) HeadersType

func (hdrs *MessageHeaders) HeadersType() MessageHeadersType

HeadersType gets the type of headers.

The function returns the following values:

  • messageHeadersType header's type.

func (*MessageHeaders) List

func (hdrs *MessageHeaders) List(name string) string

List gets the value of header name in hdrs.

Use this for headers whose values are comma-delimited lists, and which are therefore allowed to appear multiple times in the headers. For non-list-valued headers, use messageheaders.GetOne.

If name appears multiple times in hdrs, messageheaders.GetList will concatenate all of the values together, separated by commas. This is sometimes awkward to parse (eg, WWW-Authenticate, Set-Cookie), but you have to be able to deal with it anyway, because the HTTP spec explicitly states that this transformation is allowed, and so an upstream proxy could do the same thing.

The function takes the following parameters:

  • name: header name.

The function returns the following values:

  • utf8 (optional) header's value or NULL if not found.

func (*MessageHeaders) One

func (hdrs *MessageHeaders) One(name string) string

One gets the value of header name in hdrs.

Use this for headers whose values are *not* comma-delimited lists, and which therefore can only appear at most once in the headers. For list-valued headers, use messageheaders.GetList.

If hdrs does erroneously contain multiple copies of the header, it is not defined which one will be returned. (Ideally, it will return whichever one makes libsoup most compatible with other HTTP implementations.).

The function takes the following parameters:

  • name: header name.

The function returns the following values:

  • utf8 (optional) header's value or NULL if not found.

func (*MessageHeaders) Ranges

func (hdrs *MessageHeaders) Ranges(totalLength int64) ([]Range, bool)

Ranges parses hdrs's Range header and returns an array of the requested byte ranges.

The returned array must be freed with messageheaders.FreeRanges.

If total_length is non-0, its value will be used to adjust the returned ranges to have explicit start and end values, and the returned ranges will be sorted and non-overlapping. If total_length is 0, then some ranges may have an end value of -1, as described under range, and some of the ranges may be redundant.

Beware that even if given a total_length, this function does not check that the ranges are satisfiable.

Server has built-in handling for range requests. If your server handler returns a SOUP_STATUS_OK response containing the complete response body (rather than pausing the message and returning some of the response body later), and there is a Range header in the request, then libsoup will automatically convert the response to a SOUP_STATUS_PARTIAL_CONTENT response containing only the range(s) requested by the client.

The only time you need to process the Range header yourself is if either you need to stream the response body rather than returning it all at once, or you do not already have the complete response body available, and only want to generate the parts that were actually requested by the client.

The function takes the following parameters:

  • totalLength: total_length of the response body.

The function returns the following values:

  • ranges: return location for an array of Range.
  • ok: TRUE if hdrs contained a syntactically-valid "Range" header, FALSE otherwise (in which case range and length will not be set).

func (*MessageHeaders) Remove

func (hdrs *MessageHeaders) Remove(name string)

Remove removes name from hdrs.

If there are multiple values for name, they are all removed.

The function takes the following parameters:

  • name: header name to remove.

func (*MessageHeaders) Replace

func (hdrs *MessageHeaders) Replace(name string, value string)

Replace replaces the value of the header name in hdrs with value.

See also messageheaders.Append.

The caller is expected to make sure that name and value are syntactically correct.

The function takes the following parameters:

  • name: header name to replace.
  • value: new value of name.

func (*MessageHeaders) SetContentDisposition

func (hdrs *MessageHeaders) SetContentDisposition(disposition string, params map[string]string)

SetContentDisposition sets the "Content-Disposition" header in hdrs to disposition, optionally with additional parameters specified in params.

See messageheaders.GetContentDisposition for a discussion of how Content-Disposition is used in HTTP.

The function takes the following parameters:

  • disposition: disposition-type.
  • params (optional): additional parameters.

func (*MessageHeaders) SetContentLength

func (hdrs *MessageHeaders) SetContentLength(contentLength int64)

SetContentLength sets the message body length that hdrs will declare, and sets hdrs's encoding to SOUP_ENCODING_CONTENT_LENGTH.

You do not normally need to call this; if hdrs is set to use Content-Length encoding, libsoup will automatically set its Content-Length header for you immediately before sending the headers. One situation in which this method is useful is when generating the response to a HEAD request; Calling messageheaders.SetContentLength allows you to put the correct content length into the response without needing to waste memory by filling in a response body which won't actually be sent.

The function takes the following parameters:

  • contentLength: message body length.

func (*MessageHeaders) SetContentRange

func (hdrs *MessageHeaders) SetContentRange(start int64, end int64, totalLength int64)

SetContentRange sets hdrs's Content-Range header according to the given values.

(Note that total_length is the total length of the entire resource that this is a range of, not simply end - start + 1.)

server has built-in handling for range requests, and you do not normally need to call this function youself. See messageheaders.GetRanges for more details.

The function takes the following parameters:

  • start of the range.
  • end of the range.
  • totalLength: total length of the resource, or -1 if unknown.

func (*MessageHeaders) SetContentType

func (hdrs *MessageHeaders) SetContentType(contentType string, params map[string]string)

SetContentType sets the "Content-Type" header in hdrs to content_type.

Accepts additional parameters specified in params.

The function takes the following parameters:

  • contentType: MIME type.
  • params (optional): additional parameters.

func (*MessageHeaders) SetEncoding

func (hdrs *MessageHeaders) SetEncoding(encoding Encoding)

SetEncoding sets the message body encoding that hdrs will declare.

In particular, you should use this if you are going to send a request or response in chunked encoding.

The function takes the following parameters:

  • encoding: Encoding.

func (*MessageHeaders) SetExpectations

func (hdrs *MessageHeaders) SetExpectations(expectations Expectation)

SetExpectations sets hdrs's "Expect" header according to expectations.

Currently SOUP_EXPECTATION_CONTINUE is the only known expectation value. You should set this value on a request if you are sending a large message body (eg, via POST or PUT), and want to give the server a chance to reject the request after seeing just the headers (eg, because it will require authentication before allowing you to post, or because you're POSTing to a URL that doesn't exist). This saves you from having to transmit the large request body when the server is just going to ignore it anyway.

The function takes the following parameters:

  • expectations to set.

func (*MessageHeaders) SetRange

func (hdrs *MessageHeaders) SetRange(start int64, end int64)

SetRange sets hdrs's Range header to request the indicated range.

start and end are interpreted as in a range.

If you need to request multiple ranges, use messageheaders.SetRanges.

The function takes the following parameters:

  • start of the range to request.
  • end of the range to request.

func (*MessageHeaders) SetRanges

func (hdrs *MessageHeaders) SetRanges(ranges *Range, length int)

SetRanges sets hdrs's Range header to request the indicated ranges.

If you only want to request a single range, you can use messageheaders.SetRange.

The function takes the following parameters:

  • ranges: array of Range.
  • length of range.

type MessageHeadersForEachFunc

type MessageHeadersForEachFunc func(name, value string)

MessageHeadersForEachFunc: callback passed to messageheaders.ForEach.

type MessageHeadersIter

type MessageHeadersIter struct {
	// contains filtered or unexported fields
}

MessageHeadersIter: opaque type used to iterate over a SoupMessageHeaders structure.

After intializing the iterator with messageheadersiter.Init(), call messageheadersiter.Next to fetch data from it.

You may not modify the headers while iterating over them.

An instance of this type is always passed by reference.

func MessageHeadersIterInit

func MessageHeadersIterInit(hdrs *MessageHeaders) *MessageHeadersIter

MessageHeadersIterInit initializes iter for iterating hdrs.

The function takes the following parameters:

  • hdrs: SoupMessageHeaders.

The function returns the following values:

  • iter: pointer to a SoupMessageHeadersIter structure.

func (*MessageHeadersIter) Next

func (iter *MessageHeadersIter) Next() (name string, value string, ok bool)

Next yields the next name/value pair in the messageheaders being iterated by iter.

If iter has already yielded the last header, then messageheadersiter.Next will return FALSE and name and value will be unchanged.

The function returns the following values:

  • name: pointer to a variable to return the header name in.
  • value: pointer to a variable to return the header value in.
  • ok: TRUE if another name and value were returned, FALSE if the end of the headers has been reached.

type MessageHeadersType

type MessageHeadersType C.gint

MessageHeadersType: value passed to messageheaders.New to set certain default behaviors.

const (
	// MessageHeadersRequest: request headers.
	MessageHeadersRequest MessageHeadersType = iota
	// MessageHeadersResponse: response headers.
	MessageHeadersResponse
	// MessageHeadersMultipart: multipart body part headers.
	MessageHeadersMultipart
)

func (MessageHeadersType) String

func (m MessageHeadersType) String() string

String returns the name in string for MessageHeadersType.

type MessageMetrics

type MessageMetrics struct {
	// contains filtered or unexported fields
}

MessageMetrics contains metrics collected while loading a message either from the network or the disk cache.

Metrics are not collected by default for a message, you need to add the flag SOUP_MESSAGE_COLLECT_METRICS to enable the feature.

Temporal metrics are expressed as a monotonic time and always start with a fetch start event and finish with response end. All other events are optional. An event can be 0 because it hasn't happened yet, because it's optional or because the load failed before the event reached.

Size metrics are expressed in bytes and are updated while the message is being loaded. You can connect to different message signals to get the final result of every value.

An instance of this type is always passed by reference.

func (*MessageMetrics) ConnectEnd

func (metrics *MessageMetrics) ConnectEnd() uint64

ConnectEnd: get the time immediately after the message completed the connection to the server. This includes the time for the proxy negotiation and TLS handshake.

It will be 0 if no network connection was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

The function returns the following values:

  • guint64: connection end time.

func (*MessageMetrics) ConnectStart

func (metrics *MessageMetrics) ConnectStart() uint64

ConnectStart: get the time immediately before the message started to establish the connection to the server.

It will be 0 if no network connection was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

The function returns the following values:

  • guint64: connection start time.

func (*MessageMetrics) Copy

func (metrics *MessageMetrics) Copy() *MessageMetrics

Copy copies metrics.

The function returns the following values:

  • messageMetrics: copy of metrics.

func (*MessageMetrics) DnsEnd

func (metrics *MessageMetrics) DnsEnd() uint64

DnsEnd: get the time immediately after the message completed the domain lookup name for the resource.

It will be 0 if no domain lookup was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

The function returns the following values:

  • guint64: domain lookup end time.

func (*MessageMetrics) DnsStart

func (metrics *MessageMetrics) DnsStart() uint64

DnsStart: get the time immediately before the message started the domain lookup name for the resource.

It will be 0 if no domain lookup was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

The function returns the following values:

  • guint64: domain lookup start time.

func (*MessageMetrics) FetchStart

func (metrics *MessageMetrics) FetchStart() uint64

FetchStart: get the time immediately before the message started to fetch a resource either from a remote server or local disk cache.

The function returns the following values:

  • guint64: fetch start time.

func (*MessageMetrics) RequestBodyBytesSent

func (metrics *MessageMetrics) RequestBodyBytesSent() uint64

RequestBodyBytesSent: get the number of bytes sent to the network for the request body.

This is the size of the body sent, after encodings are applied, so it might be greater than the value returned by messagemetrics.GetRequestBodySize. This value is available right before message::wrote-body signal is emitted, but you might get an intermediate value if called before.

The function returns the following values:

  • guint64: request body bytes sent.

func (*MessageMetrics) RequestBodySize

func (metrics *MessageMetrics) RequestBodySize() uint64

RequestBodySize: get the request body size in bytes. This is the size of the original body given to the request before any encoding is applied.

This value is available right before message::wrote-body signal is emitted, but you might get an intermediate value if called before.

The function returns the following values:

  • guint64: request body size.

func (*MessageMetrics) RequestHeaderBytesSent

func (metrics *MessageMetrics) RequestHeaderBytesSent() uint64

RequestHeaderBytesSent: get the number of bytes sent to the network for the request headers.

This value is available right before message::wrote-headers signal is emitted, but you might get an intermediate value if called before.

The function returns the following values:

  • guint64: request headers bytes sent.

func (*MessageMetrics) RequestStart

func (metrics *MessageMetrics) RequestStart() uint64

RequestStart: get the time immediately before the message started the request of the resource from the server or the local disk cache.

The function returns the following values:

  • guint64: request start time.

func (*MessageMetrics) ResponseBodyBytesReceived

func (metrics *MessageMetrics) ResponseBodyBytesReceived() uint64

ResponseBodyBytesReceived: get the number of bytes received from the network for the response body.

This value is available right before message::got-body signal is emitted, but you might get an intermediate value if called before. For resources loaded from the disk cache this value is always 0.

The function returns the following values:

  • guint64: response body bytes received.

func (*MessageMetrics) ResponseBodySize

func (metrics *MessageMetrics) ResponseBodySize() uint64

ResponseBodySize: get the response body size in bytes.

This is the size of the body as given to the user after all encodings are applied, so it might be greater than the value returned by messagemetrics.GetResponseBodyBytesReceived. This value is available right before message::got-body signal is emitted, but you might get an intermediate value if called before.

The function returns the following values:

  • guint64: response body size.

func (*MessageMetrics) ResponseEnd

func (metrics *MessageMetrics) ResponseEnd() uint64

ResponseEnd: get the time immediately after the message received the last bytes of the response from the server or the local disk cache.

In case of load failure, this returns the time immediately before the fetch is aborted.

The function returns the following values:

  • guint64: response end time.

func (*MessageMetrics) ResponseHeaderBytesReceived

func (metrics *MessageMetrics) ResponseHeaderBytesReceived() uint64

ResponseHeaderBytesReceived: get the number of bytes received from the network for the response headers.

This value is available right before message::got-headers signal is emitted, but you might get an intermediate value if called before. For resources loaded from the disk cache this value is always 0.

The function returns the following values:

  • guint64: response headers bytes received.

func (*MessageMetrics) ResponseStart

func (metrics *MessageMetrics) ResponseStart() uint64

ResponseStart: get the time immediately after the message received the first bytes of the response from the server or the local disk cache.

The function returns the following values:

  • guint64: response start time.

func (*MessageMetrics) TLSStart

func (metrics *MessageMetrics) TLSStart() uint64

TLSStart: get the time immediately before the message started the TLS handshake.

It will be 0 if no TLS handshake was required to fetch the resource (connection was not secure, a persistent connection was used or resource was loaded from the local disk cache).

The function returns the following values:

  • guint64 tls start time.

type MessageOverrides

type MessageOverrides struct {
}

MessageOverrides contains methods that are overridable.

type MessagePriority

type MessagePriority C.gint

MessagePriority priorities that can be set on a message to instruct the message queue to process it before any other message with lower priority.

const (
	// MessagePriorityVeryLow: lowest priority, the messages with this priority
	// will be the last ones to be attended.
	MessagePriorityVeryLow MessagePriority = iota
	// MessagePriorityLow: use this for low priority messages, a Message with
	// the default priority will be processed first.
	MessagePriorityLow
	// MessagePriorityNormal: default priotity, this is the priority assigned to
	// the Message by default.
	MessagePriorityNormal
	// MessagePriorityHigh: high priority, a Message with this priority will be
	// processed before the ones with the default priority.
	MessagePriorityHigh
	// MessagePriorityVeryHigh: highest priority, use this for very urgent
	// Message as they will be the first ones to be attended.
	MessagePriorityVeryHigh
)

func (MessagePriority) String

func (m MessagePriority) String() string

String returns the name in string for MessagePriority.

type Multipart

type Multipart struct {
	// contains filtered or unexported fields
}

Multipart represents a multipart HTTP message body, parsed according to the syntax of RFC 2046.

Of particular interest to HTTP are multipart/byte-ranges and multipart/form-data,

Although the headers of a Multipart body part will contain the full headers from that body part, libsoup does not interpret them according to MIME rules. For example, each body part is assumed to have "binary" Content-Transfer-Encoding, even if its headers explicitly state otherwise. In other words, don't try to use Multipart for handling real MIME multiparts.

An instance of this type is always passed by reference.

func NewMultipart

func NewMultipart(mimeType string) *Multipart

NewMultipart constructs a struct Multipart.

func NewMultipartFromMessage

func NewMultipartFromMessage(headers *MessageHeaders, body *glib.Bytes) *Multipart

NewMultipartFromMessage constructs a struct Multipart.

func (*Multipart) AppendFormFile

func (multipart *Multipart) AppendFormFile(controlName string, filename string, contentType string, body *glib.Bytes)

AppendFormFile adds a new MIME part containing body to multipart

Uses "Content-Disposition: form-data", as per the HTML forms specification.

The function takes the following parameters:

  • controlName: name of the control associated with this file.
  • filename (optional): name of the file, or NULL if not known.
  • contentType (optional): MIME type of the file, or NULL if not known.
  • body: file data.

func (*Multipart) AppendFormString

func (multipart *Multipart) AppendFormString(controlName string, data string)

AppendFormString adds a new MIME part containing data to multipart.

Uses "Content-Disposition: form-data", as per the HTML forms specification.

The function takes the following parameters:

  • controlName: name of the control associated with data.
  • data: body data.

func (*Multipart) AppendPart

func (multipart *Multipart) AppendPart(headers *MessageHeaders, body *glib.Bytes)

AppendPart adds a new MIME part to multipart with the given headers and body.

(The multipart will make its own copies of headers and body, so you should free your copies if you are not using them for anything else.).

The function takes the following parameters:

  • headers: MIME part headers.
  • body: MIME part body.

func (*Multipart) Length

func (multipart *Multipart) Length() int

Length gets the number of body parts in multipart.

The function returns the following values:

  • gint: number of body parts in multipart.

func (*Multipart) Part

func (multipart *Multipart) Part(part int) (*MessageHeaders, *glib.Bytes, bool)

Part gets the indicated body part from multipart.

The function takes the following parameters:

  • part number to get (counting from 0).

The function returns the following values:

  • headers: return location for the MIME part headers.
  • body: return location for the MIME part body.
  • ok: TRUE on success, FALSE if part is out of range (in which case headers and body won't be set).

func (*Multipart) ToMessage

func (multipart *Multipart) ToMessage(destHeaders *MessageHeaders) *glib.Bytes

ToMessage serializes multipart to dest_headers and dest_body.

The function takes the following parameters:

  • destHeaders headers of the HTTP message to serialize multipart to.

The function returns the following values:

  • destBody: body of the HTTP message to serialize multipart to.

type MultipartInputStream

type MultipartInputStream struct {
	gio.FilterInputStream

	*coreglib.Object
	gio.InputStream
	gio.PollableInputStream
	// contains filtered or unexported fields
}

MultipartInputStream handles streams of multipart messages.

This adds support for the multipart responses. For handling the multiple parts the user needs to wrap the gio.InputStream obtained by sending the request with a multipartinputstream and use multipartinputstream.NextPart before reading. Responses which are not wrapped will be treated like non-multipart responses.

Note that although MultipartInputStream is a gio.InputStream, you should not read directly from it, and the results are undefined if you do.

func NewMultipartInputStream

func NewMultipartInputStream(msg *Message, baseStream gio.InputStreamer) *MultipartInputStream

NewMultipartInputStream creates a new MultipartInputStream that wraps the gio.InputStream obtained by sending the message.

Reads should not be done directly through this object, use the input streams returned by multipartinputstream.NextPart or its async counterpart instead.

The function takes the following parameters:

  • msg the response is related to.
  • baseStream returned by sending the request.

The function returns the following values:

  • multipartInputStream: new MultipartInputStream.

func (*MultipartInputStream) Headers

func (multipart *MultipartInputStream) Headers() *MessageHeaders

Headers obtains the headers for the part currently being processed.

Note that the messageheaders that are returned are owned by the MultipartInputStream and will be replaced when a call is made to multipartinputstream.NextPart or its async counterpart, so if keeping the headers is required, a copy must be made.

Note that if a part had no headers at all an empty messageheaders will be returned.

The function returns the following values:

  • messageHeaders (optional): MessageHeaders containing the headers for the part currently being processed or NULL if the headers failed to parse.

func (*MultipartInputStream) NextPart

func (multipart *MultipartInputStream) NextPart(ctx context.Context) (gio.InputStreamer, error)

NextPart obtains an input stream for the next part.

When dealing with a multipart response the input stream needs to be wrapped in a MultipartInputStream and this function or its async counterpart need to be called to obtain the first part for reading.

After calling this function, multipartinputstream.GetHeaders can be used to obtain the headers for the first part. A read of 0 bytes indicates the end of the part; a new call to this function should be done at that point, to obtain the next part.

The function takes the following parameters:

  • ctx (optional): #GCancellable.

The function returns the following values:

  • inputStream (optional): new Stream, or NULL if there are no more parts.

func (*MultipartInputStream) NextPartFinish

func (multipart *MultipartInputStream) NextPartFinish(result gio.AsyncResulter) (gio.InputStreamer, error)

NextPartFinish finishes an asynchronous request for the next part.

The function takes the following parameters:

  • result: Result.

The function returns the following values:

  • inputStream (optional): newly created gio.InputStream for reading the next part or NULL if there are no more parts.

type MultipartInputStreamClass

type MultipartInputStreamClass struct {
	// contains filtered or unexported fields
}

MultipartInputStreamClass: instance of this type is always passed by reference.

func (*MultipartInputStreamClass) ParentClass

func (m *MultipartInputStreamClass) ParentClass() *gio.FilterInputStreamClass

type MultipartInputStreamOverrides

type MultipartInputStreamOverrides struct {
}

MultipartInputStreamOverrides contains methods that are overridable.

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range represents a byte range as used in the Range header.

If end is non-negative, then start and end represent the bounds of of the range, counting from 0. (Eg, the first 500 bytes would be represented as start = 0 and end = 499.)

If end is -1 and start is non-negative, then this represents a range starting at start and ending with the last byte of the requested resource body. (Eg, all but the first 500 bytes would be start = 500, and end = -1.)

If end is -1 and start is negative, then it represents a "suffix range", referring to the last -start bytes of the resource body. (Eg, the last 500 bytes would be start = -500 and end = -1.)

An instance of this type is always passed by reference.

func NewRange

func NewRange(start, end int64) Range

NewRange creates a new Range instance from the given fields. Beware that this function allocates on the Go heap; be careful when using it!

func (*Range) End

func (r *Range) End() int64

End: end of the range.

func (*Range) SetEnd

func (r *Range) SetEnd(end int64)

End: end of the range.

func (*Range) SetStart

func (r *Range) SetStart(start int64)

Start: start of the range.

func (*Range) Start

func (r *Range) Start() int64

Start: start of the range.

type SameSitePolicy

type SameSitePolicy C.gint

SameSitePolicy represents the same-site policies of a cookie.

const (
	// SameSitePolicyNone: cookie is exposed with both cross-site and same-site
	// requests.
	SameSitePolicyNone SameSitePolicy = iota
	// SameSitePolicyLax: cookie is withheld on cross-site requests but exposed
	// on cross-site navigations.
	SameSitePolicyLax
	// SameSitePolicyStrict: cookie is only exposed for same-site requests.
	SameSitePolicyStrict
)

func (SameSitePolicy) String

func (s SameSitePolicy) String() string

String returns the name in string for SameSitePolicy.

type Server

type Server struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

Server: HTTP server.

Server implements a simple HTTP server.

To begin, create a server using server.New. Add at least one handler by calling server.AddHandler or server.AddEarlyHandler; the handler will be called to process any requests underneath the path you pass. (If you want all requests to go to the same handler, just pass "/" (or NULL) for the path.)

When a new connection is accepted (or a new request is started on an existing persistent connection), the Server will emit server::request-started and then begin processing the request as described below, but note that once the message is assigned a status-code, then callbacks after that point will be skipped. Note also that it is not defined when the callbacks happen relative to various servermessage signals.

Once the headers have been read, Server will check if there is a authdomain (qv) covering the Request-URI; if so, and if the message does not contain suitable authorization, then the authdomain will set a status of SOUP_STATUS_UNAUTHORIZED on the message.

After checking for authorization, Server will look for "early" handlers (added with server.AddEarlyHandler) matching the Request-URI. If one is found, it will be run; in particular, this can be used to connect to signals to do a streaming read of the request body.

(At this point, if the request headers contain Expect: 100-continue, and a status code has been set, then Server will skip the remaining steps and return the response. If the request headers contain Expect: 100-continue and no status code has been set, Server will return a SOUP_STATUS_CONTINUE status before continuing.)

The server will then read in the response body (if present). At this point, if there are no handlers at all defined for the Request-URI, then the server will return SOUP_STATUS_NOT_FOUND to the client.

Otherwise (assuming no previous step assigned a status to the message) any "normal" handlers (added with server.AddHandler) for the message's Request-URI will be run.

Then, if the path has a WebSocket handler registered (and has not yet been assigned a status), Server will attempt to validate the WebSocket handshake, filling in the response and setting a status of SOUP_STATUS_SWITCHING_PROTOCOLS or SOUP_STATUS_BAD_REQUEST accordingly.

If the message still has no status code at this point (and has not been paused with servermessage.Pause), then it will be given a status of SOUP_STATUS_INTERNAL_SERVER_ERROR (because at least one handler ran, but returned without assigning a status).

Finally, the server will emit server::request-finished (or server::request-aborted if an I/O error occurred before handling was completed).

If you want to handle the special "*" URI (eg, "OPTIONS *"), you must explicitly register a handler for "*"; the default handler will not be used for that case.

If you want to process https connections in addition to (or instead of) http connections, you can set the server:tls-certificate property.

Once the server is set up, make one or more calls to server.Listen, server.ListenLocal, or server.ListenAll to tell it where to listen for connections. (All ports on a Server use the same handlers; if you need to handle some ports differently, such as returning different data for http and https, you'll need to create multiple SoupServers, or else check the passed-in URI in the handler function.).

Server will begin processing connections as soon as you return to (or start) the main loop for the current thread-default glib.MainContext.

func (*Server) AcceptIostream

func (server *Server) AcceptIostream(stream gio.IOStreamer, localAddr, remoteAddr gio.SocketAddresser) error

AcceptIostream adds a new client stream to the server.

The function takes the following parameters:

  • stream: OStream.
  • localAddr (optional): local Address associated with the stream.
  • remoteAddr (optional): remote Address associated with the stream.

func (*Server) AddAuthDomain

func (server *Server) AddAuthDomain(authDomain AuthDomainer)

AddAuthDomain adds an authentication domain to server.

Each auth domain will have the chance to require authentication for each request that comes in; normally auth domains will require authentication for requests on certain paths that they have been set up to watch, or that meet other criteria set by the caller. If an auth domain determines that a request requires authentication (and the request doesn't contain authentication), server will automatically reject the request with an appropriate status (401 Unauthorized or 407 Proxy Authentication Required). If the request used the SoupServer:100-continue Expectation, server will reject it before the request body is sent.

The function takes the following parameters:

  • authDomain: AuthDomain.

func (*Server) AddEarlyHandler

func (server *Server) AddEarlyHandler(path string, callback ServerCallback)

AddEarlyHandler adds an "early" handler to server for requests prefixed by path.

Note that "normal" and "early" handlers are matched up together, so if you add a normal handler for "/foo" and an early handler for "/foo/bar", then a request to "/foo/bar" (or any path below it) will run only the early handler. (But if you add both handlers at the same path, then both will get run.)

For requests under path (that have not already been assigned a status code by a authdomain or a signal handler), callback will be invoked after receiving the request headers, but before receiving the request body; the message's method and request-headers properties will be set.

Early handlers are generally used for processing requests with request bodies in a streaming fashion. If you determine that the request will contain a message body, normally you would call messagebody.SetAccumulate on the message's request-body to turn off request-body accumulation, and connect to the message's servermessage::got-chunk signal to process each chunk as it comes in.

To complete the message processing after the full message body has been read, you can either also connect to servermessage::got-body, or else you can register a non-early handler for path as well. As long as you have not set the status-code by the time servermessage::got-body is emitted, the non-early handler will be run as well.

The function takes the following parameters:

  • path (optional): toplevel path for the handler.
  • callback to invoke for requests under path.

func (*Server) AddHandler

func (server *Server) AddHandler(path string, callback ServerCallback)

AddHandler adds a handler to server for requests prefixed by path.

If path is NULL or "/", then this will be the default handler for all requests that don't have a more specific handler. (Note though that if you want to handle requests to the special "*" URI, you must explicitly register a handler for "*"; the default handler will not be used for that case.)

For requests under path (that have not already been assigned a status code by a authdomain, an early server handler, or a signal handler), callback will be invoked after receiving the request body; the servermessage's method, request-headers, and request-body properties will be set.

After determining what to do with the request, the callback must at a minimum call servermessage.SetStatus on the message to set the response status code. Additionally, it may set response headers and/or fill in the response body.

If the callback cannot fully fill in the response before returning (eg, if it needs to wait for information from a database, or another network server), it should call servermessage.Pause to tell server to not send the response right away. When the response is ready, call servermessage.Unpause to cause it to be sent.

To send the response body a bit at a time using "chunked" encoding, first call messageheaders.SetEncoding to set SOUP_ENCODING_CHUNKED on the response-headers. Then call messagebody.Append (or messagebody.AppendBytes)) to append each chunk as it becomes ready, and servermessage.Unpause to make sure it's running. (The server will automatically pause the message if it is using chunked encoding but no more chunks are available.) When you are done, call messagebody.Complete to indicate that no more chunks are coming.

The function takes the following parameters:

  • path (optional): toplevel path for the handler.
  • callback to invoke for requests under path.

func (*Server) AddWebsocketExtension

func (server *Server) AddWebsocketExtension(extensionType coreglib.Type)

AddWebsocketExtension: add support for a WebSocket extension of the given extension_type.

When a WebSocket client requests an extension of extension_type, a new websocketextension of type extension_type will be created to handle the request.

Note that websocketextensiondeflate is supported by default, use server.RemoveWebsocketExtension if you want to disable it.

The function takes the following parameters:

  • extensionType: #GType.

func (*Server) AddWebsocketHandler

func (server *Server) AddWebsocketHandler(path, origin string, protocols []string, callback ServerWebsocketCallback)

AddWebsocketHandler adds a WebSocket handler to server for requests prefixed by path.

If path is NULL or "/", then this will be the default handler for all requests that don't have a more specific handler.

When a path has a WebSocket handler registered, server will check incoming requests for WebSocket handshakes after all other handlers have run (unless some earlier handler has already set a status code on the message), and update the request's status, response headers, and response body accordingly.

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. More complicated requirements can be handled by adding a normal handler to path, and having it perform whatever checks are needed and setting a failure status code if the handshake should be rejected.

The function takes the following parameters:

  • path (optional): toplevel path for the handler.
  • origin (optional) of the connection.
  • protocols (optional): protocols supported by this handler.
  • callback to invoke for successful WebSocket requests under path.

func (*Server) ConnectRequestAborted

func (server *Server) ConnectRequestAborted(f func(message *ServerMessage)) coreglib.SignalHandle

ConnectRequestAborted is emitted when processing has failed for a message.

This could mean either that it could not be read (if server::request-read has not been emitted for it yet), or that the response could not be written back (if server::request-read has been emitted but server::request-finished has not been).

message is in an undefined state when this signal is emitted; the signal exists primarily to allow the server to free any state that it may have allocated in server::request-started.

func (*Server) ConnectRequestFinished

func (server *Server) ConnectRequestFinished(f func(message *ServerMessage)) coreglib.SignalHandle

ConnectRequestFinished is emitted when the server has finished writing a response to a request.

func (*Server) ConnectRequestRead

func (server *Server) ConnectRequestRead(f func(message *ServerMessage)) coreglib.SignalHandle

ConnectRequestRead is emitted when the server has successfully read a request.

message will have all of its request-side information filled in, and if the message was authenticated, client will have information about that. This signal is emitted before any (non-early) handlers are called for the message, and if it sets the message's #status_code, then normal handler processing will be skipped.

func (*Server) ConnectRequestStarted

func (server *Server) ConnectRequestStarted(f func(message *ServerMessage)) coreglib.SignalHandle

ConnectRequestStarted is emitted when the server has started reading a new request.

message will be completely blank; not even the Request-Line will have been read yet. About the only thing you can usefully do with it is connect to its signals.

If the request is read successfully, this will eventually be followed by a server::request_read signal. If a response is then sent, the request processing will end with a server::request-finished signal. If a network error occurs, the processing will instead end with server::request-aborted.

func (*Server) Disconnect

func (server *Server) Disconnect()

Disconnect closes and frees server's listening sockets.

Note that if there are currently requests in progress on server, that they will continue to be processed if server's glib.MainContext is still running.

You can call server.Listen, etc, after calling this function if you want to start listening again.

func (*Server) IsHTTPS

func (server *Server) IsHTTPS() bool

IsHTTPS checks whether server is capable of https.

In order for a server to run https, you must call server.SetTLSCertificate, or set the server:tls-certificate property, to provide it with a certificate to use.

If you are using the deprecated single-listener APIs, then a return value of TRUE indicates that the Server serves https exclusively. If you are using server.Listen, etc, then a TRUE return value merely indicates that the server is *able* to do https, regardless of whether it actually currently is or not. Use server.GetURIs to see if it currently has any https listeners.

The function returns the following values:

  • ok: TRUE if server is configured to serve https.

func (*Server) Listen

func (server *Server) Listen(address gio.SocketAddresser, options ServerListenOptions) error

Listen attempts to set up server to listen for connections on address.

If options includes SOUP_SERVER_LISTEN_HTTPS, and server has been configured for TLS, then server will listen for https connections on this port. Otherwise it will listen for plain http.

You may call this method (along with the other "listen" methods) any number of times on a server, if you want to listen on multiple ports, or set up both http and https service.

After calling this method, server will begin accepting and processing connections as soon as the appropriate glib.MainContext is run.

Note that this API does not make use of dual IPv4/IPv6 sockets; if address is an IPv6 address, it will only accept IPv6 connections. You must configure IPv4 listening separately.

The function takes the following parameters:

  • address of the interface to listen on.
  • options: listening options for this server.

func (*Server) ListenAll

func (server *Server) ListenAll(port uint, options ServerListenOptions) error

ListenAll attempts to set up server to listen for connections on all interfaces on the system.

That is, it listens on the addresses 0.0.0.0 and/or ::, depending on whether options includes SOUP_SERVER_LISTEN_IPV4_ONLY, SOUP_SERVER_LISTEN_IPV6_ONLY, or neither.) If port is specified, server will listen on that port. If it is 0, server will find an unused port to listen on. (In that case, you can use server.GetURIs to find out what port it ended up choosing.

See server.Listen for more details.

The function takes the following parameters:

  • port to listen on, or 0.
  • options: listening options for this server.

func (*Server) ListenLocal

func (server *Server) ListenLocal(port uint, options ServerListenOptions) error

ListenLocal attempts to set up server to listen for connections on "localhost".

That is, 127.0.0.1 and/or ::1, depending on whether options includes SOUP_SERVER_LISTEN_IPV4_ONLY, SOUP_SERVER_LISTEN_IPV6_ONLY, or neither). If port is specified, server will listen on that port. If it is 0, server will find an unused port to listen on. (In that case, you can use server.GetURIs to find out what port it ended up choosing.

See server.Listen for more details.

The function takes the following parameters:

  • port to listen on, or 0.
  • options: listening options for this server.

func (*Server) ListenSocket

func (server *Server) ListenSocket(socket *gio.Socket, options ServerListenOptions) error

ListenSocket attempts to set up server to listen for connections on socket.

See server.Listen for more details.

The function takes the following parameters:

  • socket: listening #GSocket.
  • options: listening options for this server.

func (*Server) Listeners

func (server *Server) Listeners() []*gio.Socket

Listeners gets server's list of listening sockets.

You should treat these sockets as read-only; writing to or modifiying any of these sockets may cause server to malfunction.

The function returns the following values:

  • sList: a list of listening sockets.

func (*Server) PauseMessage deprecated

func (server *Server) PauseMessage(msg *ServerMessage)

PauseMessage pauses I/O on msg.

This can be used when you need to return from the server handler without having the full response ready yet. Use server.UnpauseMessage to resume I/O.

This must only be called on a servermessage which was created by the Server and are currently doing I/O, such as those passed into a servercallback or emitted in a server::request-read signal.

Deprecated: Use soup_server_message_pause() instead.

The function takes the following parameters:

  • msg associated with server.

func (*Server) RemoveAuthDomain

func (server *Server) RemoveAuthDomain(authDomain AuthDomainer)

RemoveAuthDomain removes auth_domain from server.

The function takes the following parameters:

  • authDomain: AuthDomain.

func (*Server) RemoveHandler

func (server *Server) RemoveHandler(path string)

RemoveHandler removes all handlers (early and normal) registered at path.

The function takes the following parameters:

  • path: toplevel path for the handler.

func (*Server) RemoveWebsocketExtension

func (server *Server) RemoveWebsocketExtension(extensionType coreglib.Type)

RemoveWebsocketExtension removes support for WebSocket extension of type extension_type (or any subclass of extension_type) from server.

The function takes the following parameters:

  • extensionType: #GType.

func (*Server) SetTLSAuthMode

func (server *Server) SetTLSAuthMode(mode gio.TLSAuthenticationMode)

SetTLSAuthMode sets server's AuthenticationMode to use for SSL/TLS client authentication.

The function takes the following parameters:

  • mode: AuthenticationMode.

func (*Server) SetTLSCertificate

func (server *Server) SetTLSCertificate(certificate gio.TLSCertificater)

SetTLSCertificate sets server up to do https, using the given SSL/TLS certificate.

The function takes the following parameters:

  • certificate: Certificate.

func (*Server) SetTLSDatabase

func (server *Server) SetTLSDatabase(tlsDatabase gio.TLSDatabaser)

SetTLSDatabase sets server's Database to use for validating SSL/TLS client certificates.

The function takes the following parameters:

  • tlsDatabase: Database.

func (*Server) TLSAuthMode

func (server *Server) TLSAuthMode() gio.TLSAuthenticationMode

TLSAuthMode gets the server SSL/TLS client authentication mode.

The function returns the following values:

  • tlsAuthenticationMode: AuthenticationMode.

func (*Server) TLSCertificate

func (server *Server) TLSCertificate() gio.TLSCertificater

TLSCertificate gets the server SSL/TLS certificate.

The function returns the following values:

  • tlsCertificate (optional) or NULL.

func (*Server) TLSDatabase

func (server *Server) TLSDatabase() gio.TLSDatabaser

TLSDatabase gets the server SSL/TLS database.

The function returns the following values:

  • tlsDatabase (optional): Database.

func (*Server) URIs

func (server *Server) URIs() []*glib.URI

URIs gets a list of URIs corresponding to the interfaces server is listening on.

These will contain IP addresses, not hostnames, and will also indicate whether the given listener is http or https.

Note that if you used server.ListenAll the returned URIs will use the addresses 0.0.0.0 and ::, rather than actually returning separate URIs for each interface on the system.

The function returns the following values:

  • sList: list of #GUris, which you must free when you are done with it.

func (*Server) UnpauseMessage deprecated

func (server *Server) UnpauseMessage(msg *ServerMessage)

UnpauseMessage resumes I/O on msg.

Use this to resume after calling server.PauseMessage, or after adding a new chunk to a chunked response.

I/O won't actually resume until you return to the main loop.

This must only be called on a servermessage which was created by the Server and are currently doing I/O, such as those passed into a servercallback or emitted in a server::request-read signal.

Deprecated: Use soup_server_message_unpause() instead.

The function takes the following parameters:

  • msg associated with server.

type ServerCallback

type ServerCallback func(server *Server, msg *ServerMessage, path string, query map[string]string)

ServerCallback: callback used to handle requests to a server.

path and query contain the likewise-named components of the Request-URI, subject to certain assumptions. By default, server decodes all percent-encoding in the URI path, such that "/foo2Fbar" is treated the same as "/foo/bar". If your server is serving resources in some non-POSIX-filesystem namespace, you may want to distinguish those as two distinct paths. In that case, you can set the server:raw-paths property when creating the server, and it will leave those characters undecoded.

query contains the query component of the Request-URI parsed according to the rules for HTML form handling. Although this is the only commonly-used query string format in HTTP, there is nothing that actually requires that HTTP URIs use that format; if your server needs to use some other format, you can just ignore query, and call message.GetURI and parse the URI's query field yourself.

See server.AddHandler and server.AddEarlyHandler for details of what handlers can/should do.

type ServerClass

type ServerClass struct {
	// contains filtered or unexported fields
}

ServerClass: instance of this type is always passed by reference.

func (*ServerClass) Padding

func (s *ServerClass) Padding() [6]unsafe.Pointer

type ServerListenOptions

type ServerListenOptions C.guint

ServerListenOptions options to pass to server.Listen, etc.

SOUP_SERVER_LISTEN_IPV4_ONLY and SOUP_SERVER_LISTEN_IPV6_ONLY only make sense with server.ListenAll and server.ListenLocal, not plain server.Listen (which simply listens on whatever kind of socket you give it). And you cannot specify both of them in a single call.

const (
	// ServerListenHTTPS: listen for https connections rather than plain http.
	ServerListenHTTPS ServerListenOptions = 0b1
	// ServerListenIPv4Only: only listen on IPv4 interfaces.
	ServerListenIPv4Only ServerListenOptions = 0b10
	// ServerListenIPv6Only: only listen on IPv6 interfaces.
	ServerListenIPv6Only ServerListenOptions = 0b100
)

func (ServerListenOptions) Has

Has returns true if s contains other.

func (ServerListenOptions) String

func (s ServerListenOptions) String() string

String returns the names in string for ServerListenOptions.

type ServerMessage

type ServerMessage struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

ServerMessage: HTTP server request and response pair.

A SoupServerMessage represents an HTTP message that is being sent or received on a server.

server will create SoupServerMessages automatically for incoming requests, which your application will receive via handlers.

Note that libsoup's terminology here does not quite match the HTTP specification: in RFC 2616, an "HTTP-message" is *either* a Request, *or* a Response. In libsoup, a ServerMessage combines both the request and the response.

func (*ServerMessage) ConnectAcceptCertificate

func (msg *ServerMessage) ConnectAcceptCertificate(f func(tlsPeerCertificate gio.TLSCertificater, tlsPeerErrors gio.TLSCertificateFlags) (ok bool)) coreglib.SignalHandle

ConnectAcceptCertificate is emitted during the msg's connection TLS handshake after client TLS certificate has been received. You can return TRUE to accept tls_certificate despite tls_errors.

func (*ServerMessage) ConnectConnected

func (msg *ServerMessage) ConnectConnected(f func()) coreglib.SignalHandle

ConnectConnected is emitted when the msg's socket is connected and the TLS handshake completed.

func (*ServerMessage) ConnectDisconnected

func (msg *ServerMessage) ConnectDisconnected(f func()) coreglib.SignalHandle

ConnectDisconnected is emitted when the msg's socket is disconnected.

func (*ServerMessage) ConnectFinished

func (msg *ServerMessage) ConnectFinished(f func()) coreglib.SignalHandle

ConnectFinished is emitted when all HTTP processing is finished for a message. (After servermessage::wrote-body).

func (*ServerMessage) ConnectGotBody

func (msg *ServerMessage) ConnectGotBody(f func()) coreglib.SignalHandle

ConnectGotBody is emitted after receiving the complete request body.

func (*ServerMessage) ConnectGotChunk

func (msg *ServerMessage) ConnectGotChunk(f func(chunk *glib.Bytes)) coreglib.SignalHandle

ConnectGotChunk is emitted after receiving a chunk of a message body.

Note that "chunk" in this context means any subpiece of the body, not necessarily the specific HTTP 1.1 chunks sent by the other side.

func (*ServerMessage) ConnectGotHeaders

func (msg *ServerMessage) ConnectGotHeaders(f func()) coreglib.SignalHandle

ConnectGotHeaders is emitted after receiving the Request-Line and request headers.

func (*ServerMessage) ConnectWroteBody

func (msg *ServerMessage) ConnectWroteBody(f func()) coreglib.SignalHandle

ConnectWroteBody is emitted immediately after writing the complete response body for a message.

func (*ServerMessage) ConnectWroteBodyData

func (msg *ServerMessage) ConnectWroteBodyData(f func(chunkSize uint)) coreglib.SignalHandle

ConnectWroteBodyData is emitted immediately after writing a portion of the message body to the network.

func (*ServerMessage) ConnectWroteChunk

func (msg *ServerMessage) ConnectWroteChunk(f func()) coreglib.SignalHandle

ConnectWroteChunk is emitted immediately after writing a body chunk for a message.

Note that this signal is not parallel to servermessage::got-chunk; it is emitted only when a complete chunk (added with messagebody.Append or messagebody.AppendBytes has been written. To get more useful continuous progress information, use servermessage::wrote-body-data.

func (*ServerMessage) ConnectWroteHeaders

func (msg *ServerMessage) ConnectWroteHeaders(f func()) coreglib.SignalHandle

ConnectWroteHeaders is emitted immediately after writing the response headers for a message.

func (*ServerMessage) ConnectWroteInformational

func (msg *ServerMessage) ConnectWroteInformational(f func()) coreglib.SignalHandle

ConnectWroteInformational is emitted immediately after writing a 1xx (Informational) response.

func (*ServerMessage) HTTPVersion

func (msg *ServerMessage) HTTPVersion() HTTPVersion

HTTPVersion: get the HTTP version of msg.

The function returns the following values:

  • httpVersion: HTTPVersion.

func (*ServerMessage) IsOptionsPing

func (msg *ServerMessage) IsOptionsPing() bool

IsOptionsPing gets if msg represents an OPTIONS message with the path *.

The function returns the following values:

  • ok: TRUE if is an OPTIONS ping.

func (*ServerMessage) LocalAddress

func (msg *ServerMessage) LocalAddress() gio.SocketAddresser

LocalAddress retrieves the gio.SocketAddress associated with the local end of a connection.

The function returns the following values:

  • socketAddress (optional): Address associated with the local end of a connection, it may be NULL if you used server.AcceptIostream.

func (*ServerMessage) Method

func (msg *ServerMessage) Method() string

Method: get the HTTP method of msg.

The function returns the following values:

  • utf8: HTTP method.

func (*ServerMessage) Pause

func (msg *ServerMessage) Pause()

Pause pauses I/O on msg.

This can be used when you need to return from the server handler without having the full response ready yet. Use servermessage.Unpause to resume I/O.

func (*ServerMessage) ReasonPhrase

func (msg *ServerMessage) ReasonPhrase() string

ReasonPhrase: get the HTTP reason phrase of msg.

The function returns the following values:

  • utf8 (optional): reason phrase.

func (*ServerMessage) RemoteAddress

func (msg *ServerMessage) RemoteAddress() gio.SocketAddresser

RemoteAddress retrieves the gio.SocketAddress associated with the remote end of a connection.

The function returns the following values:

  • socketAddress (optional): Address associated with the remote end of a connection, it may be NULL if you used server.AcceptIostream.

func (*ServerMessage) RemoteHost

func (msg *ServerMessage) RemoteHost() string

RemoteHost retrieves the IP address associated with the remote end of a connection.

The function returns the following values:

  • utf8 (optional): IP address associated with the remote end of a connection, it may be NULL if you used server.AcceptIostream.

func (*ServerMessage) RequestBody

func (msg *ServerMessage) RequestBody() *MessageBody

RequestBody: get the request body of msg.

The function returns the following values:

  • messageBody: MessageBody.

func (*ServerMessage) RequestHeaders

func (msg *ServerMessage) RequestHeaders() *MessageHeaders

RequestHeaders: get the request headers of msg.

The function returns the following values:

  • messageHeaders with the request headers.

func (*ServerMessage) ResponseBody

func (msg *ServerMessage) ResponseBody() *MessageBody

ResponseBody: get the response body of msg.

The function returns the following values:

  • messageBody: MessageBody.

func (*ServerMessage) ResponseHeaders

func (msg *ServerMessage) ResponseHeaders() *MessageHeaders

ResponseHeaders: get the response headers of msg.

The function returns the following values:

  • messageHeaders with the response headers.

func (*ServerMessage) SetHTTPVersion

func (msg *ServerMessage) SetHTTPVersion(version HTTPVersion)

SetHTTPVersion: set the HTTP version of msg.

The function takes the following parameters:

  • version: HTTPVersion.

func (*ServerMessage) SetRedirect

func (msg *ServerMessage) SetRedirect(statusCode uint, redirectUri string)

SetRedirect sets msg's status_code to status_code and adds a Location header pointing to redirect_uri. Use this from a server when you want to redirect the client to another URI.

redirect_uri can be a relative URI, in which case it is interpreted relative to msg's current URI. In particular, if redirect_uri is just a path, it will replace the path *and query* of msg's URI.

The function takes the following parameters:

  • statusCode: 3xx status code.
  • redirectUri: URI to redirect msg to.

func (*ServerMessage) SetResponse

func (msg *ServerMessage) SetResponse(contentType string, respUse MemoryUse, respBody string)

SetResponse: convenience function to set the response body of a ServerMessage. If content_type is NULL, the response body must be empty as well.

The function takes the following parameters:

  • contentType (optional): MIME Content-Type of the body.
  • respUse describing how to handle resp_body.
  • respBody (optional): a data buffer containing the body of the message response.

func (*ServerMessage) SetStatus

func (msg *ServerMessage) SetStatus(statusCode uint, reasonPhrase string)

SetStatus sets msg's status code to status_code.

If status_code is a known value and reason_phrase is NULL, the reason_phrase will be set automatically.

The function takes the following parameters:

  • statusCode: HTTP status code.
  • reasonPhrase (optional): reason phrase.

func (*ServerMessage) Socket

func (msg *ServerMessage) Socket() *gio.Socket

Socket retrieves the gio.Socket that msg is associated with.

If you are using this method to observe when multiple requests are made on the same persistent HTTP connection (eg, as the ntlm-test test program does), you will need to pay attention to socket destruction as well (eg, by using weak references), so that you do not get fooled when the allocator reuses the memory address of a previously-destroyed socket to represent a new socket.

The function returns the following values:

  • socket (optional) that msg is associated with, NULL if you used server.AcceptIostream.

func (*ServerMessage) Status

func (msg *ServerMessage) Status() uint

Status: get the HTTP status code of msg.

The function returns the following values:

  • guint: HTTP status code.

func (*ServerMessage) StealConnection

func (msg *ServerMessage) StealConnection() gio.IOStreamer

StealConnection: "Steals" the HTTP connection associated with msg from its Server. This happens immediately, regardless of the current state of the connection; if the response to msg has not yet finished being sent, then it will be discarded; you can steal the connection from a servermessage::wrote-informational or servermessage::wrote-body signal handler if you need to wait for part or all of the response to be sent.

Note that when calling this function from C, msg will most likely be freed as a side effect.

The function returns the following values:

  • ioStream formerly associated with msg (or NULL if msg was no longer associated with a connection). No guarantees are made about what kind of OStream is returned.

func (*ServerMessage) TLSPeerCertificate

func (msg *ServerMessage) TLSPeerCertificate() gio.TLSCertificater

TLSPeerCertificate gets the peer's Certificate associated with msg's connection. Note that this is not set yet during the emission of SoupServerMessage::accept-certificate signal.

The function returns the following values:

  • tlsCertificate (optional) msg's TLS peer certificate, or NULL if msg's connection is not SSL.

func (*ServerMessage) TLSPeerCertificateErrors

func (msg *ServerMessage) TLSPeerCertificateErrors() gio.TLSCertificateFlags

TLSPeerCertificateErrors gets the errors associated with validating msg's TLS peer certificate. Note that this is not set yet during the emission of SoupServerMessage::accept-certificate signal.

The function returns the following values:

  • tlsCertificateFlags with msg's TLS peer certificate errors.

func (*ServerMessage) URI

func (msg *ServerMessage) URI() *glib.URI

URI: get msg's URI.

The function returns the following values:

  • uri: #GUri.

func (*ServerMessage) Unpause

func (msg *ServerMessage) Unpause()

Unpause resumes I/O on msg.

Use this to resume after calling servermessage.Pause, or after adding a new chunk to a chunked response. I/O won't actually resume until you return to the main loop.

type ServerMessageClass

type ServerMessageClass struct {
	// contains filtered or unexported fields
}

ServerMessageClass: instance of this type is always passed by reference.

type ServerMessageOverrides

type ServerMessageOverrides struct {
}

ServerMessageOverrides contains methods that are overridable.

type ServerOverrides

type ServerOverrides struct {
	// The function takes the following parameters:
	//
	RequestAborted func(msg *ServerMessage)
	// The function takes the following parameters:
	//
	RequestFinished func(msg *ServerMessage)
	// The function takes the following parameters:
	//
	RequestRead func(msg *ServerMessage)
	// The function takes the following parameters:
	//
	RequestStarted func(msg *ServerMessage)
}

ServerOverrides contains methods that are overridable.

type ServerWebsocketCallback

type ServerWebsocketCallback func(server *Server, msg *ServerMessage, path string, connection *WebsocketConnection)

ServerWebsocketCallback: callback used to handle WebSocket requests to a Server.

The callback will be invoked after sending the handshake response back to the client (and is only invoked if the handshake was successful).

path contains the path of the Request-URI, subject to the same rules as servercallback (qv).

type Session

type Session struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

Session: soup session state object.

Session is the object that controls client-side HTTP. A Session encapsulates all of the state that libsoup is keeping on behalf of your program; cached HTTP connections, authentication information, etc. It also keeps track of various global options and features that you are using.

Most applications will only need a single Session; the primary reason you might need multiple sessions is if you need to have multiple independent authentication contexts. (Eg, you are connecting to a server and authenticating as two different users at different times; the easiest way to ensure that each message is sent with the authentication information you intended is to use one session for the first user, and a second session for the other user.)

Additional Session functionality is provided by sessionfeature objects, which can be added to a session with session.AddFeature or session.AddFeatureByType For example, logger provides support for logging HTTP traffic, contentdecoder provides support for compressed response handling, and contentsniffer provides support for HTML5-style response body content sniffing. Additionally, subtypes of auth can be added as features, to add support for additional authentication types.

All SoupSessions are created with a authmanager, and support for SOUP_TYPE_AUTH_BASIC and SOUP_TYPE_AUTH_DIGEST. Additionally, sessions using the plain Session class (rather than one of its deprecated subtypes) have a contentdecoder by default.

Note that all async methods will invoke their callbacks on the thread-default context at the time of the function call.

func NewSession

func NewSession() *Session

NewSession creates a Session with the default options.

The function returns the following values:

  • session: new session.

func (*Session) Abort

func (session *Session) Abort()

Abort cancels all pending requests in session and closes all idle persistent connections.

func (*Session) AcceptLanguage

func (session *Session) AcceptLanguage() string

AcceptLanguage: get the value used by session for the "Accept-Language" header on new requests.

The function returns the following values:

  • utf8 (optional): accept language string.

func (*Session) AcceptLanguageAuto

func (session *Session) AcceptLanguageAuto() bool

AcceptLanguageAuto gets whether session automatically sets the "Accept-Language" header on new requests.

The function returns the following values:

  • ok: TRUE if session sets "Accept-Language" header automatically, or FALSE otherwise.

func (*Session) AddFeature

func (session *Session) AddFeature(feature SessionFeaturer)

AddFeature adds feature's functionality to session. You cannot add multiple features of the same glib.Type to a session.

See the main Session documentation for information on what features are present in sessions by default.

The function takes the following parameters:

  • feature: object that implements SessionFeature.

func (*Session) AddFeatureByType

func (session *Session) AddFeatureByType(featureType coreglib.Type)

AddFeatureByType: if feature_type is the type of a class that implements sessionfeature, this creates a new feature of that type and adds it to session as with session.AddFeature. You can use this when you don't need to customize the new feature in any way. Adding multiple features of the same feature_type is not allowed.

If feature_type is not a sessionfeature type, this gives each existing feature on session the chance to accept feature_type as a "subfeature". This can be used to add new auth types, for instance.

See the main Session documentation for information on what features are present in sessions by default.

The function takes the following parameters:

  • featureType: #GType.

func (*Session) AsyncResultMessage

func (session *Session) AsyncResultMessage(result gio.AsyncResulter) *Message

AsyncResultMessage gets the message of the result asynchronous operation This is useful to get the message of an asynchronous operation started by session from its gio.AsyncReadyCallback.

The function takes the following parameters:

  • result passed to your callback.

The function returns the following values:

  • message (optional) or NULL if result is not a valid session async operation result.

func (*Session) ConnectRequestQueued

func (session *Session) ConnectRequestQueued(f func(msg *Message)) coreglib.SignalHandle

ConnectRequestQueued is emitted when a request is queued on session.

When sending a request, first session::request-queued is emitted, indicating that the session has become aware of the request.

After a connection is available to send the request various message signals are emitted as the message is processed. If the message is requeued, it will emit message::restarted, which will then be followed by other message signals when the message is re-sent.

Eventually, the message will emit message::finished. Normally, this signals the completion of message processing. However, it is possible that the application will requeue the message from the "finished" handler. In that case the process will loop back.

Eventually, a message will reach "finished" and not be requeued. At that point, the session will emit session::request-unqueued to indicate that it is done with the message.

To sum up: session::request-queued and session::request-unqueued are guaranteed to be emitted exactly once, but message::finished (and all of the other message signals) may be invoked multiple times for a given message.

func (*Session) ConnectRequestUnqueued

func (session *Session) ConnectRequestUnqueued(f func(msg *Message)) coreglib.SignalHandle

ConnectRequestUnqueued is emitted when a request is removed from session's queue, indicating that session is done with it.

See session::request-queued for a detailed description of the message lifecycle within a session.

func (*Session) Feature

func (session *Session) Feature(featureType coreglib.Type) *SessionFeature

Feature gets the feature in session of type feature_type.

The function takes the following parameters:

  • featureType of the feature to get.

The function returns the following values:

  • sessionFeature (optional) or NULL. The feature is owned by session.

func (*Session) FeatureForMessage

func (session *Session) FeatureForMessage(featureType coreglib.Type, msg *Message) *SessionFeature

FeatureForMessage gets the feature in session of type feature_type, provided that it is not disabled for msg.

The function takes the following parameters:

  • featureType of the feature to get.
  • msg: Message.

The function returns the following values:

  • sessionFeature (optional) The feature is owned by session.

func (*Session) HasFeature

func (session *Session) HasFeature(featureType coreglib.Type) bool

HasFeature tests if session has at a feature of type feature_type (which can be the type of either a sessionfeature, or else a subtype of some class managed by another feature, such as auth).

The function takes the following parameters:

  • featureType of the class of features to check for.

The function returns the following values:

  • ok: TRUE or FALSE.

func (*Session) IdleTimeout

func (session *Session) IdleTimeout() uint

IdleTimeout: get the timeout in seconds for idle connection lifetime currently used by session.

The function returns the following values:

  • guint: timeout in seconds.

func (*Session) LocalAddress

func (session *Session) LocalAddress() *gio.InetSocketAddress

LocalAddress: get the gio.InetSocketAddress to use for the client side of connections in session.

The function returns the following values:

  • inetSocketAddress (optional): SocketAddress.

func (*Session) MaxConns

func (session *Session) MaxConns() uint

MaxConns: get the maximum number of connections that session can open at once.

The function returns the following values:

  • guint: maximum number of connections.

func (*Session) MaxConnsPerHost

func (session *Session) MaxConnsPerHost() uint

MaxConnsPerHost: get the maximum number of connections that session can open at once to a given host.

The function returns the following values:

  • guint: maximum number of connections per host.

func (*Session) PreconnectFinish

func (session *Session) PreconnectFinish(result gio.AsyncResulter) error

PreconnectFinish: complete a preconnect async operation started with session.PreconnectAsync.

The function takes the following parameters:

  • result passed to your callback.

func (*Session) ProxyResolver

func (session *Session) ProxyResolver() *gio.ProxyResolver

ProxyResolver: get the gio.ProxyResolver currently used by session.

The function returns the following values:

  • proxyResolver (optional) or NULL if proxies are disabled in session.

func (*Session) RemoteConnectable

func (session *Session) RemoteConnectable() *gio.SocketConnectable

RemoteConnectable gets the remote connectable if one set.

The function returns the following values:

  • socketConnectable (optional): Connectable.

func (*Session) RemoveFeature

func (session *Session) RemoveFeature(feature SessionFeaturer)

RemoveFeature removes feature's functionality from session.

The function takes the following parameters:

  • feature that has previously been added to session.

func (*Session) RemoveFeatureByType

func (session *Session) RemoveFeatureByType(featureType coreglib.Type)

RemoveFeatureByType removes all features of type feature_type (or any subclass of feature_type) from session.

The function takes the following parameters:

  • featureType: #GType.

func (*Session) Send

func (session *Session) Send(ctx context.Context, msg *Message) (gio.InputStreamer, error)

Send: synchronously sends msg and waits for the beginning of a response.

On success, a gio.InputStream will be returned which you can use to read the response body. ("Success" here means only that an HTTP response was received and understood; it does not necessarily mean that a 2xx class status code was received.)

If non-NULL, cancellable can be used to cancel the request; session.Send will return a G_IO_ERROR_CANCELLED error. Note that with requests that have side effects (eg, POST, PUT, DELETE) it is possible that you might cancel the request after the server acts on it, but before it returns a response, leaving the remote resource in an unknown state.

If msg is requeued due to a redirect or authentication, the initial (3xx/401/407) response body will be suppressed, and session.Send will only return once a final response has been received.

The function takes the following parameters:

  • ctx (optional): #GCancellable.
  • msg: Message.

The function returns the following values:

  • inputStream for reading the response body, or NULL on error.

func (*Session) SendAndRead

func (session *Session) SendAndRead(ctx context.Context, msg *Message) (*glib.Bytes, error)

SendAndRead: synchronously sends msg and reads the response body.

On success, a glib.Bytes will be returned with the response body. This function should only be used when the resource to be retrieved is not too long and can be stored in memory.

See session.Send for more details on the general semantics.

The function takes the following parameters:

  • ctx (optional): #GCancellable.
  • msg: Message.

The function returns the following values:

  • bytes or NULL on error.

func (*Session) SendAndReadFinish

func (session *Session) SendAndReadFinish(result gio.AsyncResulter) (*glib.Bytes, error)

SendAndReadFinish gets the response to a session.SendAndReadAsync.

If successful, returns a glib.Bytes with the response body.

The function takes the following parameters:

  • result passed to your callback.

The function returns the following values:

  • bytes or NULL on error.

func (*Session) SendAndSplice

func (session *Session) SendAndSplice(ctx context.Context, msg *Message, outStream gio.OutputStreamer, flags gio.OutputStreamSpliceFlags) (int, error)

SendAndSplice: synchronously sends msg and splices the response body stream into out_stream.

See session.Send for more details on the general semantics.

The function takes the following parameters:

  • ctx (optional): #GCancellable.
  • msg: Message.
  • outStream: Stream.
  • flags: set of StreamSpliceFlags.

The function returns the following values:

  • gssize containing the size of the data spliced, or -1 if an error occurred.

func (*Session) SendAndSpliceFinish

func (session *Session) SendAndSpliceFinish(result gio.AsyncResulter) (int, error)

SendAndSpliceFinish gets the response to a session.SendAndSpliceAsync.

The function takes the following parameters:

  • result passed to your callback.

The function returns the following values:

  • gssize containing the size of the data spliced, or -1 if an error occurred.

func (*Session) SendFinish

func (session *Session) SendFinish(result gio.AsyncResulter) (gio.InputStreamer, error)

SendFinish gets the response to a session.SendAsync call.

If successful returns a gio.InputStream that can be used to read the response body.

The function takes the following parameters:

  • result passed to your callback.

The function returns the following values:

  • inputStream for reading the response body, or NULL on error.

func (*Session) SetAcceptLanguage

func (session *Session) SetAcceptLanguage(acceptLanguage string)

SetAcceptLanguage: set the value to use for the "Accept-Language" header on messages sent from session.

If accept_language is NULL then no "Accept-Language" will be included in requests. See session:accept-language for more information.

The function takes the following parameters:

  • acceptLanguage languages string.

func (*Session) SetAcceptLanguageAuto

func (session *Session) SetAcceptLanguageAuto(acceptLanguageAuto bool)

SetAcceptLanguageAuto: set whether session will automatically set the "Accept-Language" header on requests using a value generated from system languages based on glib.GetLanguageNames().

See session:accept-language-auto for more information.

The function takes the following parameters:

  • acceptLanguageAuto: value to set.

func (*Session) SetIdleTimeout

func (session *Session) SetIdleTimeout(timeout uint)

SetIdleTimeout: set a timeout in seconds for idle connection lifetime to be used by session on new connections.

See session:idle-timeout for more information.

The function takes the following parameters:

  • timeout in seconds.

func (*Session) SetProxyResolver

func (session *Session) SetProxyResolver(proxyResolver gio.ProxyResolverer)

SetProxyResolver: set a gio.ProxyResolver to be used by session on new connections.

If proxy_resolver is NULL then no proxies will be used. See session:proxy-resolver for more information.

The function takes the following parameters:

  • proxyResolver (optional) or NULL.

func (*Session) SetTLSDatabase

func (session *Session) SetTLSDatabase(tlsDatabase gio.TLSDatabaser)

SetTLSDatabase: set a gio.TLSDatabase to be used by session on new connections.

If tls_database is NULL then certificate validation will always fail. See session:tls-database for more information.

The function takes the following parameters:

  • tlsDatabase (optional): Database.

func (*Session) SetTLSInteraction

func (session *Session) SetTLSInteraction(tlsInteraction *gio.TLSInteraction)

SetTLSInteraction: set a gio.TLSInteraction to be used by session on new connections.

If tls_interaction is NULL then client certificate validation will always fail.

See session:tls-interaction for more information.

The function takes the following parameters:

  • tlsInteraction (optional): Interaction.

func (*Session) SetTimeout

func (session *Session) SetTimeout(timeout uint)

SetTimeout: set a timeout in seconds for socket I/O operations to be used by session on new connections.

See session:timeout for more information.

The function takes the following parameters:

  • timeout in seconds.

func (*Session) SetUserAgent

func (session *Session) SetUserAgent(userAgent string)

SetUserAgent: set the value to use for the "User-Agent" header on messages sent from session.

If user_agent has trailing whitespace, session will append its own product token (eg, libsoup/3.0.0) to the end of the header for you. If user_agent is NULL then no "User-Agent" will be included in requests. See session:user-agent for more information.

The function takes the following parameters:

  • userAgent: user agent string.

func (*Session) TLSDatabase

func (session *Session) TLSDatabase() gio.TLSDatabaser

TLSDatabase: get the gio.TLSDatabase currently used by session.

The function returns the following values:

  • tlsDatabase (optional): Database.

func (*Session) TLSInteraction

func (session *Session) TLSInteraction() *gio.TLSInteraction

TLSInteraction: get the gio.TLSInteraction currently used by session.

The function returns the following values:

  • tlsInteraction (optional): Interaction.

func (*Session) Timeout

func (session *Session) Timeout() uint

Timeout: get the timeout in seconds for socket I/O operations currently used by session.

The function returns the following values:

  • guint: timeout in seconds.

func (*Session) UserAgent

func (session *Session) UserAgent() string

UserAgent: get the value used by session for the "User-Agent" header on new requests.

The function returns the following values:

  • utf8 (optional): user agent string.

func (*Session) WebsocketConnectFinish

func (session *Session) WebsocketConnectFinish(result gio.AsyncResulter) (*WebsocketConnection, error)

WebsocketConnectFinish gets the websocketconnection response to a session.WebsocketConnectAsync call.

If successful, returns a websocketconnection that can be used to communicate with the server.

The function takes the following parameters:

  • result passed to your callback.

The function returns the following values:

  • websocketConnection: new WebsocketConnection, or NULL on error.

type SessionClass

type SessionClass struct {
	// contains filtered or unexported fields
}

SessionClass: instance of this type is always passed by reference.

type SessionError

type SessionError C.gint

SessionError: Session error.

const (
	// SessionErrorParsing server's response could not be parsed.
	SessionErrorParsing SessionError = iota
	// SessionErrorEncoding server's response was in an unsupported format.
	SessionErrorEncoding
	// SessionErrorTooManyRedirects: message has been redirected too many times.
	SessionErrorTooManyRedirects
	// SessionErrorTooManyRestarts: message has been restarted too many times.
	SessionErrorTooManyRestarts
	// SessionErrorRedirectNoLocation: failed to redirect message because
	// Location header was missing or empty in response.
	SessionErrorRedirectNoLocation
	// SessionErrorRedirectBadURI: failed to redirect message because Location
	// header contains an invalid URI.
	SessionErrorRedirectBadURI
	// SessionErrorMessageAlreadyInQueue: message is already in the session
	// queue. Messages can only be reused after unqueued.
	SessionErrorMessageAlreadyInQueue
)

func (SessionError) String

func (s SessionError) String() string

String returns the name in string for SessionError.

type SessionFeature

type SessionFeature struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

SessionFeature: interface for miscellaneous session features.

SessionFeature is the interface used by classes that extend the functionality of a session. Some features like HTTP authentication handling are implemented internally via SoupSessionFeatures. Other features can be added to the session by the application. (Eg, logger, cookiejar.)

See session.AddFeature, etc, to add a feature to a session.

SessionFeature wraps an interface. This means the user can get the underlying type by calling Cast().

func BaseSessionFeature

func BaseSessionFeature(obj SessionFeaturer) *SessionFeature

BaseSessionFeature returns the underlying base object.

type SessionFeaturer

type SessionFeaturer interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

SessionFeaturer describes SessionFeature's interface methods.

type SessionOverrides

type SessionOverrides struct {
	// The function takes the following parameters:
	//
	RequestQueued func(msg *Message)
	// The function takes the following parameters:
	//
	RequestUnqueued func(msg *Message)
}

SessionOverrides contains methods that are overridable.

type Status

type Status C.gint

Status: 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.

const (
	// StatusNone: no status available. (Eg, the message has not been sent yet).
	StatusNone Status = 0
	// StatusContinue: 100 Continue (HTTP).
	StatusContinue Status = 100
	// StatusSwitchingProtocols: 101 Switching Protocols (HTTP).
	StatusSwitchingProtocols Status = 101
	// StatusProcessing: 102 Processing (WebDAV).
	StatusProcessing Status = 102
	// StatusOK: 200 Success (HTTP). Also used by many lower-level soup routines
	// to indicate success.
	StatusOK Status = 200
	// StatusCreated: 201 Created (HTTP).
	StatusCreated Status = 201
	// StatusAccepted: 202 Accepted (HTTP).
	StatusAccepted Status = 202
	// StatusNonAuthoritative: 203 Non-Authoritative Information (HTTP).
	StatusNonAuthoritative Status = 203
	// StatusNoContent: 204 No Content (HTTP).
	StatusNoContent Status = 204
	// StatusResetContent: 205 Reset Content (HTTP).
	StatusResetContent Status = 205
	// StatusPartialContent: 206 Partial Content (HTTP).
	StatusPartialContent Status = 206
	// StatusMultiStatus: 207 Multi-Status (WebDAV).
	StatusMultiStatus Status = 207
	// StatusMultipleChoices: 300 Multiple Choices (HTTP).
	StatusMultipleChoices Status = 300
	// StatusMovedPermanently: 301 Moved Permanently (HTTP).
	StatusMovedPermanently Status = 301
	// StatusFound: 302 Found (HTTP).
	StatusFound Status = 302
	// StatusMovedTemporarily: 302 Moved Temporarily (old name, RFC 2068).
	StatusMovedTemporarily Status = 302
	// StatusSeeOther: 303 See Other (HTTP).
	StatusSeeOther Status = 303
	// StatusNotModified: 304 Not Modified (HTTP).
	StatusNotModified Status = 304
	// StatusUseProxy: 305 Use Proxy (HTTP).
	StatusUseProxy Status = 305
	// StatusNotAppearingInThisProtocol: 306 [Unused] (HTTP).
	StatusNotAppearingInThisProtocol Status = 306
	// StatusTemporaryRedirect: 307 Temporary Redirect (HTTP).
	StatusTemporaryRedirect Status = 307
	// StatusPermanentRedirect: 308 Permanent Redirect (HTTP).
	StatusPermanentRedirect Status = 308
	// StatusBadRequest: 400 Bad Request (HTTP).
	StatusBadRequest Status = 400
	// StatusUnauthorized: 401 Unauthorized (HTTP).
	StatusUnauthorized Status = 401
	// StatusPaymentRequired: 402 Payment Required (HTTP).
	StatusPaymentRequired Status = 402
	// StatusForbidden: 403 Forbidden (HTTP).
	StatusForbidden Status = 403
	// StatusNotFound: 404 Not Found (HTTP).
	StatusNotFound Status = 404
	// StatusMethodNotAllowed: 405 Method Not Allowed (HTTP).
	StatusMethodNotAllowed Status = 405
	// StatusNotAcceptable: 406 Not Acceptable (HTTP).
	StatusNotAcceptable Status = 406
	// StatusProxyAuthenticationRequired: 407 Proxy Authentication Required
	// (HTTP).
	StatusProxyAuthenticationRequired Status = 407
	// StatusProxyUnauthorized: shorter alias for
	// SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED.
	StatusProxyUnauthorized Status = 407
	// StatusRequestTimeout: 408 Request Timeout (HTTP).
	StatusRequestTimeout Status = 408
	// StatusConflict: 409 Conflict (HTTP).
	StatusConflict Status = 409
	// StatusGone: 410 Gone (HTTP).
	StatusGone Status = 410
	// StatusLengthRequired: 411 Length Required (HTTP).
	StatusLengthRequired Status = 411
	// StatusPreconditionFailed: 412 Precondition Failed (HTTP).
	StatusPreconditionFailed Status = 412
	// StatusRequestEntityTooLarge: 413 Request Entity Too Large (HTTP).
	StatusRequestEntityTooLarge Status = 413
	// StatusRequestURITooLong: 414 Request-URI Too Long (HTTP).
	StatusRequestURITooLong Status = 414
	// StatusUnsupportedMediaType: 415 Unsupported Media Type (HTTP).
	StatusUnsupportedMediaType Status = 415
	// StatusRequestedRangeNotSatisfiable: 416 Requested Range Not Satisfiable
	// (HTTP).
	StatusRequestedRangeNotSatisfiable Status = 416
	// StatusInvalidRange: shorter alias for
	// SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE.
	StatusInvalidRange Status = 416
	// StatusExpectationFailed: 417 Expectation Failed (HTTP).
	StatusExpectationFailed Status = 417
	// StatusMisdirectedRequest: 421 Misdirected Request.
	StatusMisdirectedRequest Status = 421
	// StatusUnprocessableEntity: 422 Unprocessable Entity (WebDAV).
	StatusUnprocessableEntity Status = 422
	// StatusLocked: 423 Locked (WebDAV).
	StatusLocked Status = 423
	// StatusFailedDependency: 424 Failed Dependency (WebDAV).
	StatusFailedDependency Status = 424
	// StatusInternalServerError: 500 Internal Server Error (HTTP).
	StatusInternalServerError Status = 500
	// StatusNotImplemented: 501 Not Implemented (HTTP).
	StatusNotImplemented Status = 501
	// StatusBadGateway: 502 Bad Gateway (HTTP).
	StatusBadGateway Status = 502
	// StatusServiceUnavailable: 503 Service Unavailable (HTTP).
	StatusServiceUnavailable Status = 503
	// StatusGatewayTimeout: 504 Gateway Timeout (HTTP).
	StatusGatewayTimeout Status = 504
	// StatusHTTPVersionNotSupported: 505 HTTP Version Not Supported (HTTP).
	StatusHTTPVersionNotSupported Status = 505
	// StatusInsufficientStorage: 507 Insufficient Storage (WebDAV).
	StatusInsufficientStorage Status = 507
	// StatusNotExtended: 510 Not Extended (RFC 2774).
	StatusNotExtended Status = 510
)

func (Status) String

func (s Status) String() string

String returns the name in string for Status.

type TLDError

type TLDError C.gint

TLDError: error codes for SOUP_TLD_ERROR.

const (
	// TldErrorInvalidHostname: hostname was syntactically invalid.
	TldErrorInvalidHostname TLDError = iota
	// TldErrorIsIPAddress: passed-in "hostname" was actually an IP address (and
	// thus has no base domain or public suffix).
	TldErrorIsIPAddress
	// TldErrorNotEnoughDomains: passed-in hostname did not have
	// enough components. Eg, calling tld_get_base_domain on
	// <literal>"co.uk"</literal>.
	TldErrorNotEnoughDomains
	// TldErrorNoBaseDomain: passed-in hostname has no recognized public suffix.
	TldErrorNoBaseDomain
	// TldErrorNoPslData: public Suffix List was not available.
	TldErrorNoPslData
)

func (TLDError) String

func (t TLDError) String() string

String returns the name in string for TLDError.

type URIComponent

type URIComponent C.gint

URIComponent: enum values passed to uri_copy to indicate the components of the URI that should be updated with the given values.

const (
	// URINone: no component.
	URINone URIComponent = iota
	// URIScheme: URI scheme component.
	URIScheme
	// URIUser: URI user component.
	URIUser
	// URIPassword: URI password component.
	URIPassword
	// URIAuthParams: URI authentication parameters component.
	URIAuthParams
	// URIHost: URI host component.
	URIHost
	// URIPort: URI port component.
	URIPort
	// URIPath: URI path component.
	URIPath
	// URIQuery: URI query component.
	URIQuery
	// URIFragment: URI fragment component.
	URIFragment
)

func (URIComponent) String

func (u URIComponent) String() string

String returns the name in string for URIComponent.

type WebsocketCloseCode

type WebsocketCloseCode C.gint

WebsocketCloseCode: pre-defined close codes that can be passed to websocketconnection.Close or received from websocketconnection.GetCloseCode.

However, other codes are also allowed.

const (
	// WebsocketCloseNormal: normal, non-error close.
	WebsocketCloseNormal WebsocketCloseCode = 1000
	// WebsocketCloseGoingAway: client/server is going away.
	WebsocketCloseGoingAway WebsocketCloseCode = 1001
	// WebsocketCloseProtocolError: protocol error occurred.
	WebsocketCloseProtocolError WebsocketCloseCode = 1002
	// WebsocketCloseUnsupportedData: endpoint received data of a type that it
	// does not support.
	WebsocketCloseUnsupportedData WebsocketCloseCode = 1003
	// WebsocketCloseNoStatus: reserved value indicating that no close code was
	// present; must not be sent.
	WebsocketCloseNoStatus WebsocketCloseCode = 1005
	// WebsocketCloseAbnormal: reserved value indicating that the connection was
	// closed abnormally; must not be sent.
	WebsocketCloseAbnormal WebsocketCloseCode = 1006
	// WebsocketCloseBadData: endpoint received data that was invalid (eg,
	// non-UTF-8 data in a text message).
	WebsocketCloseBadData WebsocketCloseCode = 1007
	// WebsocketClosePolicyViolation: generic error code indicating some sort of
	// policy violation.
	WebsocketClosePolicyViolation WebsocketCloseCode = 1008
	// WebsocketCloseTooBig: endpoint received a message that is too big to
	// process.
	WebsocketCloseTooBig WebsocketCloseCode = 1009
	// WebsocketCloseNoExtension: client is closing the connection because the
	// server failed to negotiate a required extension.
	WebsocketCloseNoExtension WebsocketCloseCode = 1010
	// WebsocketCloseServerError: server is closing the connection because it
	// was unable to fulfill the request.
	WebsocketCloseServerError WebsocketCloseCode = 1011
	// WebsocketCloseTLSHandshake: reserved value indicating that the TLS
	// handshake failed; must not be sent.
	WebsocketCloseTLSHandshake WebsocketCloseCode = 1015
)

func (WebsocketCloseCode) String

func (w WebsocketCloseCode) String() string

String returns the name in string for WebsocketCloseCode.

type WebsocketConnection

type WebsocketConnection struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

WebsocketConnection: webSocket Protocol

Provides support for the WebSocket (http://tools.ietf.org/html/rfc6455) protocol.

To connect to a WebSocket server, create a session and call session.WebsocketConnectAsync. To accept WebSocket connections, create a server and add a handler to it with server.AddWebsocketHandler.

(Lower-level support is available via websocket_client_prepare_handshake and websocket_client_verify_handshake, for handling the client side of the WebSocket handshake, and websocket_server_process_handshake for handling the server side.)

WebsocketConnection handles the details of WebSocket communication. You can use websocketconnection.SendText and websocketconnection.SendBinary to send data, and the websocketconnection::message signal to receive data. (WebsocketConnection currently only supports asynchronous I/O.).

func NewWebsocketConnection

func NewWebsocketConnection(stream gio.IOStreamer, uri *glib.URI, typ WebsocketConnectionType, origin, protocol string, extensions []WebsocketExtensioner) *WebsocketConnection

NewWebsocketConnection creates a WebsocketConnection on stream with the given active extensions.

This should be called after completing the handshake to begin using the WebSocket protocol.

The function takes the following parameters:

  • stream connected to the WebSocket server.
  • uri: URI of the connection.
  • typ: type of connection (client/side).
  • origin (optional): origin of the client.
  • protocol (optional) in use.
  • extensions of WebsocketExtension objects.

The function returns the following values:

  • websocketConnection: new WebsocketConnection.

func (*WebsocketConnection) Close

func (self *WebsocketConnection) Close(code uint16, data string)

Close the connection in an orderly fashion.

Note that until the websocketconnection::closed signal fires, the connection is not yet completely closed. The close message is not even sent until the main loop runs.

The code and data are sent to the peer along with the close request. If code is SOUP_WEBSOCKET_CLOSE_NO_STATUS a close message with no body (without code and data) is sent. Note that the data must be UTF-8 valid.

The function takes the following parameters:

  • code: close code.
  • data (optional): close data.

func (*WebsocketConnection) CloseCode

func (self *WebsocketConnection) CloseCode() uint16

CloseCode: get the close code received from the WebSocket peer.

This only becomes valid once the WebSocket is in the SOUP_WEBSOCKET_STATE_CLOSED state. The value will often be in the websocketclosecode enumeration, but may also be an application defined close code.

The function returns the following values:

  • gushort: close code or zero.

func (*WebsocketConnection) CloseData

func (self *WebsocketConnection) CloseData() string

CloseData: get the close data received from the WebSocket peer.

This only becomes valid once the WebSocket is in the SOUP_WEBSOCKET_STATE_CLOSED state. The data may be freed once the main loop is run, so copy it if you need to keep it around.

The function returns the following values:

  • utf8: close data or NULL.

func (*WebsocketConnection) ConnectClosed

func (self *WebsocketConnection) ConnectClosed(f func()) coreglib.SignalHandle

ConnectClosed is emitted when the connection has completely closed.

This happens either due to an orderly close from the peer, one initiated via websocketconnection.Close or a fatal error condition that caused a close.

This signal will be emitted once.

func (*WebsocketConnection) ConnectClosing

func (self *WebsocketConnection) ConnectClosing(f func()) coreglib.SignalHandle

ConnectClosing: this signal will be emitted during an orderly close.

func (*WebsocketConnection) ConnectError

func (self *WebsocketConnection) ConnectError(f func(err error)) coreglib.SignalHandle

ConnectError is emitted when an error occurred on the WebSocket.

This may be fired multiple times. Fatal errors will be followed by the websocketconnection::closed signal being emitted.

func (*WebsocketConnection) ConnectMessage

func (self *WebsocketConnection) ConnectMessage(f func(typ int, message *glib.Bytes)) coreglib.SignalHandle

ConnectMessage is emitted when we receive a message from the peer.

As a convenience, the message data will always be NULL-terminated, but the NUL byte will not be included in the length count.

func (*WebsocketConnection) ConnectPong

func (self *WebsocketConnection) ConnectPong(f func(message *glib.Bytes)) coreglib.SignalHandle

ConnectPong is emitted when we receive a Pong frame (solicited or unsolicited) from the peer.

As a convenience, the message data will always be NULL-terminated, but the NUL byte will not be included in the length count.

func (*WebsocketConnection) ConnectionType

func (self *WebsocketConnection) ConnectionType() WebsocketConnectionType

ConnectionType: get the connection type (client/server) of the connection.

The function returns the following values:

  • websocketConnectionType: connection type.

func (*WebsocketConnection) Extensions

func (self *WebsocketConnection) Extensions() []WebsocketExtensioner

Extensions: get the extensions chosen via negotiation with the peer.

The function returns the following values:

  • list of WebsocketExtension objects.

func (*WebsocketConnection) IOStream

func (self *WebsocketConnection) IOStream() gio.IOStreamer

IOStream: get the I/O stream the WebSocket is communicating over.

The function returns the following values:

  • ioStream webSocket's I/O stream.

func (*WebsocketConnection) KeepaliveInterval

func (self *WebsocketConnection) KeepaliveInterval() uint

KeepaliveInterval gets the keepalive interval in seconds or 0 if disabled.

The function returns the following values:

  • guint: keepalive interval.

func (*WebsocketConnection) MaxIncomingPayloadSize

func (self *WebsocketConnection) MaxIncomingPayloadSize() uint64

MaxIncomingPayloadSize gets the maximum payload size allowed for incoming packets.

The function returns the following values:

  • guint64: maximum payload size.

func (*WebsocketConnection) Origin

func (self *WebsocketConnection) Origin() string

Origin: get the origin of the WebSocket.

The function returns the following values:

  • utf8 (optional): origin.

func (*WebsocketConnection) Protocol

func (self *WebsocketConnection) Protocol() string

Protocol: get the protocol chosen via negotiation with the peer.

The function returns the following values:

  • utf8 (optional): chosen protocol.

func (*WebsocketConnection) SendBinary

func (self *WebsocketConnection) SendBinary(data []byte)

SendBinary: send a binary message to the peer.

If length is 0, data may be NULL.

The message is queued to be sent and will be sent when the main loop is run.

The function takes the following parameters:

  • data (optional): message contents.

func (*WebsocketConnection) SendMessage

func (self *WebsocketConnection) SendMessage(typ WebsocketDataType, message *glib.Bytes)

SendMessage: send a message of the given type to the peer. Note that this method, allows to send text messages containing NULL characters.

The message is queued to be sent and will be sent when the main loop is run.

The function takes the following parameters:

  • typ: type of message contents.
  • message data as #GBytes.

func (*WebsocketConnection) SendText

func (self *WebsocketConnection) SendText(text string)

SendText: send a NULL-terminated text (UTF-8) message to the peer.

If you need to send text messages containing NULL characters use websocketconnection.SendMessage instead.

The message is queued to be sent and will be sent when the main loop is run.

The function takes the following parameters:

  • text: message contents.

func (*WebsocketConnection) SetKeepaliveInterval

func (self *WebsocketConnection) SetKeepaliveInterval(interval uint)

SetKeepaliveInterval sets the interval in seconds on when to send a ping message which will serve as a keepalive message.

If set to 0 the keepalive message is disabled.

The function takes the following parameters:

  • interval to send a ping message or 0 to disable it.

func (*WebsocketConnection) SetMaxIncomingPayloadSize

func (self *WebsocketConnection) SetMaxIncomingPayloadSize(maxIncomingPayloadSize uint64)

SetMaxIncomingPayloadSize sets the maximum payload size allowed for incoming packets.

It does not limit the outgoing packet size.

The function takes the following parameters:

  • maxIncomingPayloadSize: maximum payload size.

func (*WebsocketConnection) State

func (self *WebsocketConnection) State() WebsocketState

State: get the current state of the WebSocket.

The function returns the following values:

  • websocketState: state.

func (*WebsocketConnection) URI

func (self *WebsocketConnection) URI() *glib.URI

URI: get the URI of the WebSocket.

For servers this represents the address of the WebSocket, and for clients it is the address connected to.

The function returns the following values:

  • uri: URI.

type WebsocketConnectionClass

type WebsocketConnectionClass struct {
	// contains filtered or unexported fields
}

WebsocketConnectionClass: abstract base class for websocketconnection.

An instance of this type is always passed by reference.

type WebsocketConnectionOverrides

type WebsocketConnectionOverrides struct {
}

WebsocketConnectionOverrides contains methods that are overridable.

type WebsocketConnectionType

type WebsocketConnectionType C.gint

WebsocketConnectionType: type of a websocketconnection.

const (
	// WebsocketConnectionUnknown: unknown/invalid connection.
	WebsocketConnectionUnknown WebsocketConnectionType = iota
	// WebsocketConnectionClient: client-side connection.
	WebsocketConnectionClient
	// WebsocketConnectionServer: server-side connection.
	WebsocketConnectionServer
)

func (WebsocketConnectionType) String

func (w WebsocketConnectionType) String() string

String returns the name in string for WebsocketConnectionType.

type WebsocketDataType

type WebsocketDataType C.gint

WebsocketDataType: type of data contained in a websocketconnection::message signal.

const (
	// WebsocketDataText: UTF-8 text.
	WebsocketDataText WebsocketDataType = 1
	// WebsocketDataBinary: binary data.
	WebsocketDataBinary WebsocketDataType = 2
)

func (WebsocketDataType) String

func (w WebsocketDataType) String() string

String returns the name in string for WebsocketDataType.

type WebsocketError

type WebsocketError C.gint

WebsocketError: webSocket-related errors.

const (
	// WebsocketErrorFailed: generic error.
	WebsocketErrorFailed WebsocketError = iota
	// WebsocketErrorNotWebsocket: attempted to handshake with a server that
	// does not appear to understand WebSockets.
	WebsocketErrorNotWebsocket
	// WebsocketErrorBadHandshake: webSocket handshake failed because some
	// detail was invalid (eg, incorrect accept key).
	WebsocketErrorBadHandshake
	// WebsocketErrorBadOrigin: webSocket handshake failed because the "Origin"
	// header was not an allowed value.
	WebsocketErrorBadOrigin
)

func (WebsocketError) String

func (w WebsocketError) String() string

String returns the name in string for WebsocketError.

type WebsocketExtension

type WebsocketExtension struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

WebsocketExtension: webSocket extension

WebsocketExtension is the base class for WebSocket extension objects.

func BaseWebsocketExtension

func BaseWebsocketExtension(obj WebsocketExtensioner) *WebsocketExtension

BaseWebsocketExtension returns the underlying base object.

func (*WebsocketExtension) Configure

func (extension *WebsocketExtension) Configure(connectionType WebsocketConnectionType, params map[unsafe.Pointer]unsafe.Pointer) error

Configure configures extension with the given params.

The function takes the following parameters:

  • connectionType: either SOUP_WEBSOCKET_CONNECTION_CLIENT or SOUP_WEBSOCKET_CONNECTION_SERVER.
  • params (optional): parameters.

func (*WebsocketExtension) RequestParams

func (extension *WebsocketExtension) RequestParams() string

RequestParams: get the parameters strings to be included in the request header.

If the extension doesn't include any parameter in the request, this function returns NULL.

The function returns the following values:

  • utf8 (optional): new allocated string with the parameters.

func (*WebsocketExtension) ResponseParams

func (extension *WebsocketExtension) ResponseParams() string

ResponseParams: get the parameters strings to be included in the response header.

If the extension doesn't include any parameter in the response, this function returns NULL.

The function returns the following values:

  • utf8 (optional): new allocated string with the parameters.

type WebsocketExtensionClass

type WebsocketExtensionClass struct {
	// contains filtered or unexported fields
}

WebsocketExtensionClass class structure for the WebsocketExtension.

An instance of this type is always passed by reference.

func (*WebsocketExtensionClass) Name

func (w *WebsocketExtensionClass) Name() string

Name: name of the extension.

type WebsocketExtensionDeflate

type WebsocketExtensionDeflate struct {
	WebsocketExtension
	// contains filtered or unexported fields
}

WebsocketExtensionDeflate is a websocketextension implementing permessage-deflate (RFC 7692).

This extension is used by default in a session when websocketextensionmanager feature is present, and always used by server.

type WebsocketExtensionDeflateClass

type WebsocketExtensionDeflateClass struct {
	// contains filtered or unexported fields
}

WebsocketExtensionDeflateClass: instance of this type is always passed by reference.

func (*WebsocketExtensionDeflateClass) ParentClass

type WebsocketExtensionDeflateOverrides

type WebsocketExtensionDeflateOverrides struct {
}

WebsocketExtensionDeflateOverrides contains methods that are overridable.

type WebsocketExtensionManager

type WebsocketExtensionManager struct {
	*coreglib.Object

	SessionFeature
	// contains filtered or unexported fields
}

WebsocketExtensionManager is the sessionfeature that handles WebSockets extensions for a session.

A WebsocketExtensionManager is added to the session by default, and normally you don't need to worry about it at all. However, if you want to disable WebSocket extensions, you can remove the feature from the session with session.RemoveFeatureByType or disable it on individual requests with message.DisableFeature.

type WebsocketExtensionManagerClass

type WebsocketExtensionManagerClass struct {
	// contains filtered or unexported fields
}

WebsocketExtensionManagerClass: instance of this type is always passed by reference.

type WebsocketExtensionManagerOverrides

type WebsocketExtensionManagerOverrides struct {
}

WebsocketExtensionManagerOverrides contains methods that are overridable.

type WebsocketExtensionOverrides

type WebsocketExtensionOverrides struct {
	// Configure configures extension with the given params.
	//
	// The function takes the following parameters:
	//
	//   - connectionType: either SOUP_WEBSOCKET_CONNECTION_CLIENT or
	//     SOUP_WEBSOCKET_CONNECTION_SERVER.
	//   - params (optional): parameters.
	//
	Configure func(connectionType WebsocketConnectionType, params map[unsafe.Pointer]unsafe.Pointer) error
	// RequestParams: get the parameters strings to be included in the request
	// header.
	//
	// If the extension doesn't include any parameter in the request, this
	// function returns NULL.
	//
	// The function returns the following values:
	//
	//   - utf8 (optional): new allocated string with the parameters.
	//
	RequestParams func() string
	// ResponseParams: get the parameters strings to be included in the response
	// header.
	//
	// If the extension doesn't include any parameter in the response, this
	// function returns NULL.
	//
	// The function returns the following values:
	//
	//   - utf8 (optional): new allocated string with the parameters.
	//
	ResponseParams func() string
}

WebsocketExtensionOverrides contains methods that are overridable.

type WebsocketExtensioner

type WebsocketExtensioner interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

WebsocketExtensioner describes types inherited from class WebsocketExtension.

To get the original type, the caller must assert this to an interface or another type.

type WebsocketState

type WebsocketState C.gint

WebsocketState: state of the WebSocket connection.

const (
	// WebsocketStateOpen: connection is ready to send messages.
	WebsocketStateOpen WebsocketState = 1
	// WebsocketStateClosing: connection is in the process of closing down;
	// messages may be received, but not sent.
	WebsocketStateClosing WebsocketState = 2
	// WebsocketStateClosed: connection is completely closed down.
	WebsocketStateClosed WebsocketState = 3
)

func (WebsocketState) String

func (w WebsocketState) String() string

String returns the name in string for WebsocketState.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL