soup.message
Module for [Message] class
Types 3
Represents an HTTP message being sent or received.
A #SoupMessage represents an HTTP message that is being sent or received.
You would create a #SoupMessage with [soup.message.Message.new_] or [soup.message.Message.newFromUri], set up its fields appropriately, and send it.
property@Message:status-code will normally be a enum@Status value, eg, [soup.types.Status.Ok], though of course it might actually be an unknown status code. property@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 property@Message:reason-phrase in user-visible messages. Rather, you should look at property@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 #SoupMessage combines both the request and the response.
MessageGidBuilder builder()Get builder for [soup.message.Message] Returns: New builder objectglib.uri.Uri firstParty() @propertyGet `firstParty` property. Returns: The [glib.uri.Uri] loaded in the application when the message was queued.void firstParty(glib.uri.Uri propval) @propertySet `firstParty` property. Params: propval = The [glib.uri.Uri] loaded in the application when the message was queued.void flags(soup.types.MessageFlags propval) @propertySet `flags` property. Params: propval = Various message options.soup.types.HTTPVersion httpVersion() @propertyGet `httpVersion` property. Returns: The HTTP protocol version to use.bool isOptionsPing() @propertyGet `isOptionsPing` property. Returns: Whether the message is an OPTIONS ping.void isOptionsPing(bool propval) @propertySet `isOptionsPing` property. Params: propval = Whether the message is an OPTIONS ping.bool isTopLevelNavigation() @propertyGet `isTopLevelNavigation` property. Returns: Set when the message is navigating between top level domains.void isTopLevelNavigation(bool propval) @propertySet `isTopLevelNavigation` property. Params: propval = Set when the message is navigating between top level domains.void method(string propval) @propertySet `method` property. Params: propval = The message's HTTP method.soup.types.MessagePriority priority() @propertyGet `priority` property. Returns: Sets the priority of the #SoupMessage. See [soup.message.Message.setPriority] for further details.void priority(soup.types.MessagePriority propval) @propertySet `priority` property. Params: propval = Sets the priority of the #SoupMessage. See [soup.message.Message.setPriority] for further details.string reasonPhrase() @propertyGet `reasonPhrase` property. Returns: The HTTP response reason phrase.gio.socket_address.SocketAddress remoteAddress() @propertyGet `remoteAddress` property. Returns: The remote [gio.socket_address.SocketAddress] of the connection associated with the message.soup.message_headers.MessageHeaders requestHeaders() @propertyGet `requestHeaders` property. Returns: The HTTP request headers.soup.message_headers.MessageHeaders responseHeaders() @propertyGet `responseHeaders` property. Returns: The HTTP response headers.glib.uri.Uri siteForCookies() @propertyGet `siteForCookies` property. Returns: Site used to compare cookies against. Used for SameSite cookie support.void siteForCookies(glib.uri.Uri propval) @propertySet `siteForCookies` property. Params: propval = Site used to compare cookies against. Used for SameSite cookie support.string tlsCiphersuiteName() @propertyGet `tlsCiphersuiteName` property. Returns: The Name of TLS ciphersuite negotiated for this message connection.gio.tls_certificate.TlsCertificate tlsPeerCertificate() @propertyGet `tlsPeerCertificate` property. Returns: The peer's [gio.tls_certificate.TlsCertificate] associated with the message.gio.types.TlsCertificateFlags tlsPeerCertificateErrors() @propertyGet `tlsPeerCertificateErrors` property. Returns: The verification errors on `property@Message:tls-peer-certificate`.gio.types.TlsProtocolVersion tlsProtocolVersion() @propertyGet `tlsProtocolVersion` property. Returns: The TLS protocol version negotiated for the message connection.void uri(glib.uri.Uri propval) @propertySet `uri` property. Params: propval = The message's Request-URI.soup.message.Message newFromEncodedForm(string method, string uriString, string encodedForm)Creates a new #SoupMessage 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...soup.message.Message newFromMultipart(string uriString, soup.multipart.Multipart multipart)Creates a new #SoupMessage and sets it up to send multipart to uri_string via POST.soup.message.Message newFromUri(string method, glib.uri.Uri uri)Creates a new empty #SoupMessage, which will connect to uri.soup.message.Message newOptionsPing(glib.uri.Uri baseUri)Creates a new #SoupMessage to send `OPTIONS *` to a server. The path of base_uri will be ignored.void addFlags(soup.types.MessageFlags flags)Adds flags to the set of msg's flags.void disableFeature(gobject.types.GType featureType)Disables the actions of `ifaceSessionFeature`s with the given feature_type (or a subclass of that type) on msg.ulong getConnectionId()Returns the unique idenfier for the last connection used.glib.uri.Uri getFirstParty()Gets msg's first-party [glib.uri.Uri]. Returns: the msg's first party #GUrisoup.types.MessageFlags getFlags()Gets the flags on msg. Returns: the flagsbool getForceHttp1()Returns whether HTTP/1 version is currently demanded for the msg send. Returns: true, when HTTP/1 is demanded, false otherwise.soup.types.HTTPVersion getHttpVersion()Gets the HTTP version of msg.bool getIsOptionsPing()Gets whether msg is intended to be used to send `OPTIONS *` to a server. Returns: true if the message is options ping, or false otherwisebool getIsTopLevelNavigation()Returns if this message is set as a top level navigation.string getMethod()Returns the method of this message. Returns: A method such as `SOUPMETHODGET`soup.message_metrics.MessageMetrics getMetrics()Get the `structMessageMetrics` of msg.soup.types.MessagePriority getPriority()Retrieves the `enumMessagePriority`.string getReasonPhrase()Returns the reason phrase for the status of this message. Returns: the phrasegio.socket_address.SocketAddress getRemoteAddress()Get the remote [gio.socket_address.SocketAddress] of the connection associated with the message.soup.message_headers.MessageHeaders getRequestHeaders()Returns the headers sent with the request. Returns: The #SoupMessageHeaderssoup.message_headers.MessageHeaders getResponseHeaders()Returns the headers recieved with the response. Returns: The #SoupMessageHeadersglib.uri.Uri getSiteForCookies()Gets msg's site for cookies #GUri. Returns: the msg's site for cookies #GUrisoup.types.Status getStatus()Returns the set status of this message. Returns: The #SoupStatusstring getTlsCiphersuiteName()Gets the name of the TLS ciphersuite negotiated for msg's connection. Returns: the name of the TLS ciphersuite, or null if msg's connection is not SSL.gio.tls_certificate.TlsCertificate getTlsPeerCertificate()Gets the peer's [gio.tls_certificate.TlsCertificate] associated with msg's connection.gio.types.TlsCertificateFlags getTlsPeerCertificateErrors()Gets the errors associated with validating msg's TLS peer certificate. Note that this is not set yet during the emission of `signalMessage::accept-certificate` signal. Returns: a #GTlsCertificateFl...gio.types.TlsProtocolVersion getTlsProtocolVersion()Gets the TLS protocol version negotiated for msg's connection.glib.uri.Uri getUri()Gets msg's URI. Returns: the URI msg is targeted for.bool isFeatureDisabled(gobject.types.GType featureType)Get whether `ifaceSessionFeature`s of the given feature_type (or a subclass of that type) are disabled on msg.bool isKeepalive()Determines whether or not msg's connection can be kept alive for further requests after processing msg.bool queryFlags(soup.types.MessageFlags flags)Queries if flags are present in the set of msg's flags.void removeFlags(soup.types.MessageFlags flags)Removes flags from the set of msg's flags.void setFirstParty(glib.uri.Uri firstParty)Sets first_party as the main document #GUri for msg.void setFlags(soup.types.MessageFlags flags)Sets the specified flags on msg.void setForceHttp1(bool value)Sets whether HTTP/1 version should be used when sending this message. Some connections can still override it, if needed.void setIsOptionsPing(bool isOptionsPing)Set whether msg is intended to be used to send `OPTIONS *` to a server.void setIsTopLevelNavigation(bool isTopLevelNavigation)Sets whether the current request is a top-level navitation.void setMethod(string method)Set msg's HTTP method to method.void setPriority(soup.types.MessagePriority priority)Sets the priority of a message.void setRequestBody(string contentType, gio.input_stream.InputStream stream, ptrdiff_t contentLength)Set the request body of a #SoupMessage.void setRequestBodyFromBytes(string contentType = null, glib.bytes.Bytes bytes = null)Set the request body of a #SoupMessage from [glib.bytes.Bytes].void setSiteForCookies(glib.uri.Uri siteForCookies = null)Sets siteforcookies as the policy URL for same-site cookies for msg.void setTlsClientCertificate(gio.tls_certificate.TlsCertificate certificate = null)Sets the certificate to be used by msg's connection when a client certificate is requested during the TLS handshake.void setUri(glib.uri.Uri uri)Sets msg's URI to uri.void tlsClientCertificatePasswordRequestComplete()Completes a certificate password request.gulong connectAcceptCertificate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.tls_certificate.TlsCertificate)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gio.types.TlsCertificateFlags)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : soup.message.Message)))
&& Parameters!T.length < 4)Connect to `AcceptCertificate` signal.gulong connectAuthenticate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.auth.Auth)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == bool)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : soup.message.Message)))
&& Parameters!T.length < 4)Connect to `Authenticate` signal.gulong connectContentSniffed(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == string[string])))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : soup.message.Message)))
&& Parameters!T.length < 4)Connect to `ContentSniffed` signal.gulong connectFinished(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `Finished` signal.gulong connectGotBody(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `GotBody` signal.gulong connectGotBodyData(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == uint)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : soup.message.Message)))
&& Parameters!T.length < 3)Connect to `GotBodyData` signal.gulong connectGotHeaders(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `GotHeaders` signal.gulong connectGotInformational(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `GotInformational` signal.gulong connectHstsEnforced(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `HstsEnforced` signal.gulong connectNetworkEvent(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gio.types.SocketClientEvent)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gio.iostream.IOStream)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : soup.message.Message)))
&& Parameters!T.length < 4)Connect to `NetworkEvent` signal.gulong connectRequestCertificate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.tls_client_connection.TlsClientConnection)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : soup.message.Message)))
&& Parameters!T.length < 3)Connect to `RequestCertificate` signal.gulong connectRequestCertificatePassword(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.tls_password.TlsPassword)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : soup.message.Message)))
&& Parameters!T.length < 3)Connect to `RequestCertificatePassword` signal.gulong connectRestarted(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `Restarted` signal.gulong connectStarting(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `Starting` signal.gulong connectWroteBody(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `WroteBody` signal.gulong connectWroteBodyData(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == uint)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : soup.message.Message)))
&& Parameters!T.length < 3)Connect to `WroteBodyData` signal.gulong connectWroteHeaders(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.message.Message)))
&& Parameters!T.length < 2)Connect to `WroteHeaders` signal.T firstParty(glib.uri.Uri propval)Set `firstParty` property. Params: propval = The [glib.uri.Uri] loaded in the application when the message was queued. Returns: Builder instance for fluent chainingT flags(soup.types.MessageFlags propval)Set `flags` property. Params: propval = Various message options. Returns: Builder instance for fluent chainingT isOptionsPing(bool propval)Set `isOptionsPing` property. Params: propval = Whether the message is an OPTIONS ping.T isTopLevelNavigation(bool propval)Set `isTopLevelNavigation` property. Params: propval = Set when the message is navigating between top level domains. Returns: Builder instance for fluent chainingT method(string propval)Set `method` property. Params: propval = The message's HTTP method. Returns: Builder instance for fluent chainingT priority(soup.types.MessagePriority propval)Set `priority` property. Params: propval = Sets the priority of the #SoupMessage. See [soup.message.Message.setPriority] for further details. Returns: Builder instance for fluent chainingT siteForCookies(glib.uri.Uri propval)Set `siteForCookies` property. Params: propval = Site used to compare cookies against. Used for SameSite cookie support. Returns: Builder instance for fluent chainingT uri(glib.uri.Uri propval)Set `uri` property. Params: propval = The message's Request-URI. Returns: Builder instance for fluent chaining