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.
soup.message.Message.statusCode will normally be a soup.types.Status value, eg, soup.types.Status.Ok, though of course it might actually be an unknown status code. soup.message.Message.reasonPhrase 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 soup.message.Message.reasonPhrase in user-visible messages. Rather, you should look at soup.message.Message.statusCode, 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() static nothrowGet builder for [soup.message.Message] Returns: New builder objectglib.uri.Uri firstParty() @property nothrowGet `firstParty` property. Returns: The [glib.uri.Uri] loaded in the application when the message was queued.void firstParty(glib.uri.Uri propval) @property nothrowSet `firstParty` property. Params: propval = The [glib.uri.Uri] loaded in the application when the message was queued.soup.types.MessageFlags flags() @property nothrowGet `flags` property. Returns: Various message options.void flags(soup.types.MessageFlags propval) @property nothrowSet `flags` property. Params: propval = Various message options.soup.types.HTTPVersion httpVersion() @property nothrowGet `httpVersion` property. Returns: The HTTP protocol version to use.bool isOptionsPing() @property nothrowGet `isOptionsPing` property. Returns: Whether the message is an OPTIONS ping.void isOptionsPing(bool propval) @property nothrowSet `isOptionsPing` property. Params: propval = Whether the message is an OPTIONS ping.bool isTopLevelNavigation() @property nothrowGet `isTopLevelNavigation` property. Returns: Set when the message is navigating between top level domains.void isTopLevelNavigation(bool propval) @property nothrowSet `isTopLevelNavigation` property. Params: propval = Set when the message is navigating between top level domains.void method(string propval) @property nothrowSet `method` property. Params: propval = The message's HTTP method.soup.types.MessagePriority priority() @property nothrowGet `priority` property. Returns: Sets the priority of the #SoupMessage. See [soup.message.Message.setPriority] for further details.void priority(soup.types.MessagePriority propval) @property nothrowSet `priority` property. Params: propval = Sets the priority of the #SoupMessage. See [soup.message.Message.setPriority] for further details.string reasonPhrase() @property nothrowGet `reasonPhrase` property. Returns: The HTTP response reason phrase.gio.socket_address.SocketAddress remoteAddress() @property nothrowGet `remoteAddress` property. Returns: The remote [gio.socket_address.SocketAddress] of the connection associated with the message.soup.message_headers.MessageHeaders requestHeaders() @property nothrowGet `requestHeaders` property. Returns: The HTTP request headers.soup.message_headers.MessageHeaders responseHeaders() @property nothrowGet `responseHeaders` property. Returns: The HTTP response headers.glib.uri.Uri siteForCookies() @property nothrowGet `siteForCookies` property. Returns: Site used to compare cookies against. Used for SameSite cookie support.void siteForCookies(glib.uri.Uri propval) @property nothrowSet `siteForCookies` property. Params: propval = Site used to compare cookies against. Used for SameSite cookie support.uint statusCode() @property nothrowGet `statusCode` property. Returns: The HTTP response status code.string tlsCiphersuiteName() @property nothrowGet `tlsCiphersuiteName` property. Returns: The Name of TLS ciphersuite negotiated for this message connection.gio.tls_certificate.TlsCertificate tlsPeerCertificate() @property nothrowGet `tlsPeerCertificate` property. Returns: The peer's [gio.tls_certificate.TlsCertificate] associated with the message.gio.types.TlsCertificateFlags tlsPeerCertificateErrors() @property nothrowGet `tlsPeerCertificateErrors` property. Returns: The verification errors on [soup.message.Message.tlsPeerCertificate].gio.types.TlsProtocolVersion tlsProtocolVersion() @property nothrowGet `tlsProtocolVersion` property. Returns: The TLS protocol version negotiated for the message connection.void uri(glib.uri.Uri propval) @property nothrowSet `uri` property. Params: propval = The message's Request-URI.soup.message.Message newFromEncodedForm(string method, string uriString, string encodedForm) static nothrowCreates 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) static nothrowCreates 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) static nothrowCreates a new empty #SoupMessage, which will connect to uri.soup.message.Message newOptionsPing(glib.uri.Uri baseUri) static nothrowCreates a new #SoupMessage to send `OPTIONS *` to a server. The path of base_uri will be ignored.void disableFeature(gobject.types.GType featureType) nothrowDisables the actions of [soup.session_feature.SessionFeature]s with the given feature_type (or a subclass of that type) on msg.glib.uri.Uri getFirstParty() nothrowGets msg's first-party [glib.uri.Uri]. Returns: the msg's first party #GUribool getForceHttp1() nothrowReturns whether HTTP/1 version is currently demanded for the msg send. Returns: true, when HTTP/1 is demanded, false otherwise.bool getIsOptionsPing() nothrowGets whether msg is intended to be used to send `OPTIONS *` to a server. Returns: true if the message is options ping, or false otherwisestring getMethod() nothrowReturns the method of this message. Returns: A method such as `SOUP_METHOD_GET`soup.message_metrics.MessageMetrics getMetrics() nothrowGet the [soup.message_metrics.MessageMetrics] of msg.string getReasonPhrase() nothrowReturns the reason phrase for the status of this message. Returns: the phrasegio.socket_address.SocketAddress getRemoteAddress() nothrowGet the remote [gio.socket_address.SocketAddress] of the connection associated with the message.soup.message_headers.MessageHeaders getRequestHeaders() nothrowReturns the headers sent with the request. Returns: The #SoupMessageHeaderssoup.message_headers.MessageHeaders getResponseHeaders() nothrowReturns the headers recieved with the response. Returns: The #SoupMessageHeadersglib.uri.Uri getSiteForCookies() nothrowGets msg's site for cookies #GUri. Returns: the msg's site for cookies #GUrisoup.types.Status getStatus() nothrowReturns the set status of this message. Returns: The #SoupStatusstring getTlsCiphersuiteName() nothrowGets 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() nothrowGets the peer's [gio.tls_certificate.TlsCertificate] associated with msg's connection.gio.types.TlsCertificateFlags getTlsPeerCertificateErrors() nothrowGets the errors associated with validating msg's TLS peer certificate. Note that this is not set yet during the emission of [soup.message.Message.acceptCertificate] signal. Returns: a #GTlsCertific...gio.types.TlsProtocolVersion getTlsProtocolVersion() nothrowGets the TLS protocol version negotiated for msg's connection.bool isFeatureDisabled(gobject.types.GType featureType) nothrowGet whether [soup.session_feature.SessionFeature]s of the given feature_type (or a subclass of that type) are disabled on msg.bool isKeepalive() nothrowDetermines whether or not msg's connection can be kept alive for further requests after processing msg.bool queryFlags(soup.types.MessageFlags flags) nothrowQueries if flags are present in the set of msg's flags.void setFirstParty(glib.uri.Uri firstParty) nothrowSets first_party as the main document #GUri for msg.void setForceHttp1(bool value) nothrowSets whether HTTP/1 version should be used when sending this message. Some connections can still override it, if needed.void setIsOptionsPing(bool isOptionsPing) nothrowSet whether msg is intended to be used to send `OPTIONS *` to a server.void setIsTopLevelNavigation(bool isTopLevelNavigation) nothrowSets whether the current request is a top-level navitation.void setRequestBody(string contentType, gio.input_stream.InputStream stream, ptrdiff_t contentLength) nothrowSet the request body of a #SoupMessage.void setRequestBodyFromBytes(string contentType = null, glib.bytes.Bytes bytes = null) nothrowSet the request body of a #SoupMessage from [glib.bytes.Bytes].void setSiteForCookies(glib.uri.Uri siteForCookies = null) nothrowSets site_for_cookies as the policy URL for same-site cookies for msg.void setTlsClientCertificate(gio.tls_certificate.TlsCertificate certificate = null) nothrowSets the certificate to be used by msg's connection when a client certificate is requested during the TLS handshake.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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect to `WroteHeaders` signal.Fluent builder implementation template for soup.message.Message
T firstParty(glib.uri.Uri propval) nothrowSet `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) nothrowSet `flags` property. Params: propval = Various message options. Returns: Builder instance for fluent chainingT isOptionsPing(bool propval) nothrowSet `isOptionsPing` property. Params: propval = Whether the message is an OPTIONS ping.T isTopLevelNavigation(bool propval) nothrowSet `isTopLevelNavigation` property. Params: propval = Set when the message is navigating between top level domains. Returns: Builder instance for fluent chainingT method(string propval) nothrowSet `method` property. Params: propval = The message's HTTP method. Returns: Builder instance for fluent chainingT priority(soup.types.MessagePriority propval) nothrowSet `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) nothrowSet `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) nothrowSet `uri` property. Params: propval = The message's Request-URI. Returns: Builder instance for fluent chainingFluent builder for soup.message.Message