### Class

# Soup Message

since: 3.0

#### Description [src]

    final class Soup.Message : GObject.Object
    {
      /* No available fields */
    }

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_new()` or `soup_message_new_from_uri()`, set up its fields appropriately, and send it.

`SoupMessage:status-code` will normally be a `SoupStatus` value, eg, `SOUP_STATUS_OK`, though of course it might actually be an unknown status code. `SoupMessage: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 `SoupMessage:reason-phrase` in user-visible messages. Rather, you should look at `SoupMessage: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.

Available since: 3.0

#### Ancestors

- GObject

#### Constructors

###### soup_message_new

Creates a new empty `SoupMessage`, which will connect to `uri`.

since: 3.0

###### soup_message_new_from_encoded_form

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”, it will be set as request body.

since: 3.0

###### soup_message_new_from_multipart

Creates a new `SoupMessage` and sets it up to send `multipart` to `uri_string` via POST.

since: 3.0

###### soup_message_new_from_uri

Creates a new empty `SoupMessage`, which will connect to `uri`.

since: 3.0

###### soup_message_new_options_ping

Creates a new `SoupMessage` to send `OPTIONS *` to a server. The path of `base_uri` will be ignored.

since: 3.0

#### Instance methods

###### soup_message_add_flags

Adds `flags` to the set of `msg`‘s flags.

since: 3.0

###### soup_message_add_header_handler

Adds a signal handler to `msg` for `signal`.

since: 3.0

###### soup_message_add_status_code_handler

Adds a signal handler to `msg` for `signal`.

since: 3.0

###### soup_message_disable_feature

Disables the actions of `SoupSessionFeature`s with the given `feature_type` (or a subclass of that type) on `msg`.

since: 3.0

###### soup_message_get_connection_id

Returns the unique idenfier for the last connection used.

since: 3.0

###### soup_message_get_first_party

Gets `msg`‘s first-party `GUri`.

since: 3.0

###### soup_message_get_flags

Gets the flags on `msg`.

since: 3.0

###### soup_message_get_force_http1

Returns whether HTTP/1 version is currently demanded for the `msg` send.

since: 3.4

###### soup_message_get_http_version

Gets the HTTP version of `msg`.

since: 3.0

###### soup_message_get_is_options_ping

Gets whether `msg` is intended to be used to send `OPTIONS *` to a server.

since: 3.0

###### soup_message_get_is_top_level_navigation

Returns if this message is set as a top level navigation.

since: 3.0

###### soup_message_get_method

Returns the method of this message.

since: 3.0

###### soup_message_get_metrics

Get the `SoupMessageMetrics` of `msg`.

since: 3.0

###### soup_message_get_priority

Retrieves the `SoupMessagePriority`.

since: 3.0

###### soup_message_get_reason_phrase

Returns the reason phrase for the status of this message.

since: 3.0

###### soup_message_get_remote_address

Get the remote `GSocketAddress` of the connection associated with the message.

since: 3.0

###### soup_message_get_request_headers

Returns the headers sent with the request.

since: 3.0

###### soup_message_get_response_headers

Returns the headers recieved with the response.

since: 3.0

###### soup_message_get_site_for_cookies

Gets `msg`‘s site for cookies `GUri`.

since: 3.0

###### soup_message_get_status

Returns the set status of this message.

since: 3.0

###### soup_message_get_tls_ciphersuite_name

Gets the name of the TLS ciphersuite negotiated for `msg`‘s connection.

since: 3.0

###### soup_message_get_tls_peer_certificate

Gets the peer’s `GTlsCertificate` associated with `msg`‘s connection.

since: 3.0

###### soup_message_get_tls_peer_certificate_errors

Gets the errors associated with validating `msg`‘s TLS peer certificate. Note that this is not set yet during the emission of `SoupMessage::accept-certificate` signal.

since: 3.0

###### soup_message_get_tls_protocol_version

Gets the TLS protocol version negotiated for `msg`‘s connection.

since: 3.0

###### soup_message_get_uri

Gets `msg`‘s URI.

since: 3.0

###### soup_message_is_feature_disabled

Get whether `SoupSessionFeature`s of the given `feature_type` (or a subclass of that type) are disabled on `msg`.

since: 3.0

###### soup_message_is_keepalive

Determines whether or not `msg`‘s connection can be kept alive for further requests after processing `msg`.

since: 3.0

###### soup_message_query_flags

Queries if `flags` are present in the set of `msg`‘s flags.

since: 3.0

###### soup_message_remove_flags

Removes `flags` from the set of `msg`‘s flags.

since: 3.0

###### soup_message_set_first_party

Sets `first_party` as the main document `GUri` for `msg`.

since: 3.0

###### soup_message_set_flags

Sets the specified flags on `msg`.

since: 3.0

###### soup_message_set_force_http1

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

since: 3.4

###### soup_message_set_is_options_ping

Set whether `msg` is intended to be used to send `OPTIONS *` to a server.

since: 3.0

###### soup_message_set_is_top_level_navigation

Sets whether the current request is a top-level navitation.

since: 3.0

###### soup_message_set_method

Set `msg`‘s HTTP method to `method`.

since: 3.0

###### soup_message_set_priority

Sets the priority of a message.

since: 3.0

###### soup_message_set_request_body

Set the request body of a `SoupMessage`.

since: 3.0

###### soup_message_set_request_body_from_bytes

Set the request body of a `SoupMessage` from `GBytes`.

since: 3.0

###### soup_message_set_site_for_cookies

Sets `site_for_cookies` as the policy URL for same-site cookies for `msg`.

since: 3.0

###### soup_message_set_tls_client_certificate

Sets the `certificate` to be used by `msg`‘s connection when a client certificate is requested during the TLS handshake.

since: 3.0

###### soup_message_set_uri

Sets `msg`‘s URI to `uri`.

since: 3.0

###### soup_message_tls_client_certificate_password_request_complete

Completes a certificate password request.

since: 3.0

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Soup.Message:first-party

The `GUri` loaded in the application when the message was queued.

since: 3.0

###### Soup.Message:flags

Various message options.

since: 3.0

###### Soup.Message:http-version

The HTTP protocol version to use.

since: 3.0

###### Soup.Message:is-options-ping

Whether the message is an OPTIONS ping.

since: 3.0

###### Soup.Message:is-top-level-navigation

Set when the message is navigating between top level domains.

since: 3.0

###### Soup.Message:method

The message’s HTTP method.

since: 3.0

###### Soup.Message:priority

Sets the priority of the `SoupMessage`. See `soup_message_set_priority()` for further details.

since: 3.0

###### Soup.Message:reason-phrase

The HTTP response reason phrase.

since: 3.0

###### Soup.Message:remote-address

The remote `GSocketAddress` of the connection associated with the message.

since: 3.0

###### Soup.Message:request-headers

The HTTP request headers.

since: 3.0

###### Soup.Message:response-headers

The HTTP response headers.

since: 3.0

###### Soup.Message:site-for-cookies

Site used to compare cookies against. Used for SameSite cookie support.

since: 3.0

###### Soup.Message:status-code

The HTTP response status code.

since: 3.0

###### Soup.Message:tls-ciphersuite-name

The Name of TLS ciphersuite negotiated for this message connection.

since: 3.0

###### Soup.Message:tls-peer-certificate

The peer’s `GTlsCertificate` associated with the message.

since: 3.0

###### Soup.Message:tls-peer-certificate-errors

The verification errors on `SoupMessage:tls-peer-certificate`.

since: 3.0

###### Soup.Message:tls-protocol-version

The TLS protocol version negotiated for the message connection.

since: 3.0

###### Soup.Message:uri

The message’s Request-URI.

since: 3.0

#### Signals

###### Soup.Message::accept-certificate

Emitted during the `msg`‘s connection TLS handshake after an unacceptable TLS certificate has been received.

since: 3.0

###### Soup.Message::authenticate

Emitted when the message requires authentication.

since: 3.0

###### Soup.Message::content-sniffed

This signal is emitted after `SoupMessage::got-headers`.

since: 3.0

###### Soup.Message::finished

Emitted when all HTTP processing is finished for a message.

since: 3.0

###### Soup.Message::got-body

Emitted after receiving the complete message response body.

since: 3.0

###### Soup.Message::got-body-data

Emitted after reading a portion of the message body from the network.

since: 3.4

###### Soup.Message::got-headers

Emitted after receiving the Status-Line and response headers.

since: 3.0

###### Soup.Message::got-informational

Emitted after receiving a 1xx (Informational) response for a (client-side) message.

since: 3.0

###### Soup.Message::hsts-enforced

Emitted when `SoupHSTSEnforcer` has upgraded the protocol for `msg` to HTTPS as a result of matching its domain with a HSTS policy.

since: 3.0

###### Soup.Message::network-event

Emitted to indicate that some network-related event related to `msg` has occurred.

since: 3.0

###### Soup.Message::request-certificate

Emitted during the `msg`‘s connection TLS handshake when `tls_connection` requests a certificate from the client.

since: 3.0

###### Soup.Message::request-certificate-password

Emitted during the `msg`‘s connection TLS handshake when `tls_connection` requests a certificate password from the client.

since: 3.0

###### Soup.Message::restarted

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

since: 3.0

###### Soup.Message::starting

Emitted just before a message is sent.

since: 3.0

###### Soup.Message::wrote-body

Emitted immediately after writing the complete body for a message.

since: 3.0

###### Soup.Message::wrote-body-data

Emitted immediately after writing a portion of the message body to the network.

since: 3.0

###### Soup.Message::wrote-headers

Emitted immediately after writing the request headers for a message.

since: 3.0

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

since: 2.0

#### Class structure

    struct SoupMessageClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`
  No description available.