Migrating from libsoup 2
This is a list of APIs that have been removed:
- XML-RPC support.
- Handling of
data://URIs You should use
GFilefor the former and
soup_uri_decode_data_uri()for the latter.
- Define aliases for property names You must use the string name of properties directly which works in libsoup 2 already.
SoupSession:add-feature-by-typeYou must call
SoupRequest: You should use
SoupAddresshas been replaced with
SoupSockethas been removed.
SoupProxyResolverDefaultis replaced by
SoupBufferhas been replaced by
SoupDatehas been replaced by
SoupSession:ssl-stricthas been removed in favor of using the
soup_session_cancel_message()has been removed instead you pass a
GCancellableto APIs and call
Moved authenticate signal
SoupSession::authenticate signal has been replaced by
SoupMessage::authenticate. It now allows returning
TRUE to signify if
you will handle authentication which allows for asynchronous handling.
Structs are private
You can no longer directly access various structs such as
SoupMessage. These are
now accessed by getters and setters. See below for direct conversions:
|Struct field||Getter/Setter function|
|SoupMessage.response_body||See section on IO|
Similar struct changes exist for
SoupCookie but have very straightforward replacements.
URI type changed
SoupURI type has been replaced with the
GUri type which has
GUri is generally as simple as
SOUP_HTTP_URI_FLAGS, NULL). You may want to add
G_URI_FLAGS_PARSE_RELAXED to accept input that used to be considered valid.
Note that unlike
GUri is an immutable type so you cannot change the
contents of one after it has been constructed. We provide
soup_uri_copy() to aid
in modifying them.
The equivalent behavior to
soup_uri_to_string (uri, FALSE)
g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD).
GUri does not provide any function to check for equality
soup_uri_equal() still exists.
OPTIONS message with a path of
* is no longer a valid URI and has
been replaced with
Status codes no longer used for internal errors
SoupStatus was used to hold libsoup errors
SOUP_STATUS_IS_TRANSPORT_ERROR()). Now all of these errors are propagated up
through the normal
GError method on the various APIs to send
messages. Here is a mapping chart between the status codes and new errors:
|Old Status Codes||New
All IO is now GIOStream-based
Previously there were ways to allow libsoup to read data into buffers and for
you to read from those buffers such as
libsoup no longer stores a buffer of data for you to read from and instead it
GInputStream which you read from using normal GIO APIs.
If you want to simply request a buffer and nothing more you can use the
This also applies to writing data where you can set a
soup_message_set_request_body() or use the convenience API
soup_message_set_request_body_from_bytes() to use a
Clarification on thread-safety
In libsoup 2 there was an attempt at making various APIs of the library thread-safe. However this was never well tested, maintained, or documented.
libsoup 3 was initially designed to behave in line with other GObject libraries. Once you
SoupSession all usage of that session must happen on the same
thread. However, in version 3.2 thread safety support was introduced
again, with the same approach as libsoup2.