### Class

# Soup Message

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

#### Ancestors

- GObject

#### Constructors

###### soup_message_new

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

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

###### soup_message_new_from_multipart

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

###### soup_message_new_from_uri

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

###### soup_message_new_options_ping

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

#### Instance methods

###### soup_message_add_flags

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

###### soup_message_add_header_handler

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

###### soup_message_add_status_code_handler

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

###### soup_message_disable_feature

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

###### soup_message_get_connection_id

Returns the unique idenfier for the last connection used.

###### soup_message_get_first_party

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

###### soup_message_get_flags

Gets the flags on `msg`.

###### 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`.

###### soup_message_get_is_options_ping

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

###### soup_message_get_is_top_level_navigation

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

###### soup_message_get_method

Returns the method of this message.

###### soup_message_get_metrics

Get the `SoupMessageMetrics` of `msg`.

###### soup_message_get_priority

Retrieves the `SoupMessagePriority`.

###### soup_message_get_reason_phrase

Returns the reason phrase for the status of this message.

###### soup_message_get_remote_address

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

###### soup_message_get_request_headers

Returns the headers sent with the request.

###### soup_message_get_response_headers

Returns the headers recieved with the response.

###### soup_message_get_site_for_cookies

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

###### soup_message_get_status

Returns the set status of this message.

###### soup_message_get_tls_ciphersuite_name

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

###### soup_message_get_tls_peer_certificate

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

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

###### soup_message_get_tls_protocol_version

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

###### soup_message_get_uri

Gets `msg`‘s URI.

###### soup_message_is_feature_disabled

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

###### soup_message_is_keepalive

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

###### soup_message_query_flags

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

###### soup_message_remove_flags

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

###### soup_message_set_first_party

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

###### soup_message_set_flags

Sets the specified flags on `msg`.

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

###### soup_message_set_is_top_level_navigation

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

###### soup_message_set_method

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

###### soup_message_set_priority

Sets the priority of a message.

###### soup_message_set_request_body

Set the request body of a `SoupMessage`.

###### soup_message_set_request_body_from_bytes

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

###### soup_message_set_site_for_cookies

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

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

###### soup_message_set_uri

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

###### soup_message_tls_client_certificate_password_request_complete

Completes a certificate password request.

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

###### Soup.Message:flags

Various message options.

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

The HTTP protocol version to use.

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

Whether the message is an OPTIONS ping.

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

Set when the message is navigating between top level domains.

###### Soup.Message:method

The message’s HTTP method.

###### Soup.Message:priority

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

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

The HTTP response reason phrase.

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

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

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

The HTTP request headers.

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

The HTTP response headers.

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

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

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

The HTTP response status code.

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

The Name of TLS ciphersuite negotiated for this message connection.

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

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

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

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

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

The TLS protocol version negotiated for the message connection.

###### Soup.Message:uri

The message’s Request-URI.

#### Signals

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

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

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

Emitted when the message requires authentication.

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

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

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

Emitted when all HTTP processing is finished for a message.

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

Emitted after receiving the complete message response body.

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

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

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

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

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

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

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

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

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

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

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

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

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

Emitted just before a message is sent.

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

Emitted immediately after writing the complete body for a message.

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

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

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

Emitted immediately after writing the request headers for a message.

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

#### Class structure

    struct SoupMessageClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`
  No description available.