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.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Message self() nothrowReturns `this`, for use in `with` statements.
MessageGidBuilder builder() static nothrowGet builder for [soup.message.Message] Returns: New builder object
glib.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.
string method() @property nothrowGet `method` property. Returns: The message's HTTP method.
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.
glib.uri.Uri uri() @property nothrowGet `uri` property. Returns: The message's Request-URI.
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 addFlags(soup.types.MessageFlags flags) nothrowAdds flags to the set of msg's flags.
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.
ulong getConnectionId() nothrowReturns the unique idenfier for the last connection used.
glib.uri.Uri getFirstParty() nothrowGets msg's first-party [glib.uri.Uri]. Returns: the msg's first party #GUri
soup.types.MessageFlags getFlags() nothrowGets the flags on msg. Returns: the flags
bool getForceHttp1() nothrowReturns whether HTTP/1 version is currently demanded for the msg send. Returns: true, when HTTP/1 is demanded, false otherwise.
soup.types.HTTPVersion getHttpVersion() nothrowGets the HTTP version of msg.
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 otherwise
bool getIsTopLevelNavigation() nothrowReturns if this message is set as a top level navigation.
string 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.
soup.types.MessagePriority getPriority() nothrowRetrieves the [soup.types.MessagePriority].
string getReasonPhrase() nothrowReturns the reason phrase for the status of this message. Returns: the phrase
gio.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 #SoupMessageHeaders
soup.message_headers.MessageHeaders getResponseHeaders() nothrowReturns the headers recieved with the response. Returns: The #SoupMessageHeaders
glib.uri.Uri getSiteForCookies() nothrowGets msg's site for cookies #GUri. Returns: the msg's site for cookies #GUri
soup.types.Status getStatus() nothrowReturns the set status of this message. Returns: The #SoupStatus
string 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.
glib.uri.Uri getUri() nothrowGets msg's URI. Returns: the URI msg is targeted for.
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 removeFlags(soup.types.MessageFlags flags) nothrowRemoves flags from the set of msg's flags.
void setFirstParty(glib.uri.Uri firstParty) nothrowSets first_party as the main document #GUri for msg.
void setFlags(soup.types.MessageFlags flags) nothrowSets the specified flags on 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 setMethod(string method) nothrowSet msg's HTTP method to method.
void setPriority(soup.types.MessagePriority priority) nothrowSets the priority of a message.
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.
void setUri(glib.uri.Uri uri) nothrowSets msg's URI to uri.
void tlsClientCertificatePasswordRequestComplete() nothrowCompletes 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) 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.
Constructors
this(void * ptr, Flag!"Take" take)
this(string method, string uriString)Creates a new empty #SoupMessage, which will connect to uri.

Fluent builder implementation template for soup.message.Message

Methods
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 chaining
T flags(soup.types.MessageFlags propval) nothrowSet `flags` property. Params: propval = Various message options. Returns: Builder instance for fluent chaining
T 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 chaining
T method(string propval) nothrowSet `method` property. Params: propval = The message's HTTP method. Returns: Builder instance for fluent chaining
T 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 chaining
T 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 chaining
T uri(glib.uri.Uri propval) nothrowSet `uri` property. Params: propval = The message's Request-URI. Returns: Builder instance for fluent chaining

Fluent builder for soup.message.Message

Methods
Message build() nothrowCreate object from builder. Returns: New object