summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/libsoup-2.4-docs.sgml17
-rw-r--r--docs/reference/libsoup-2.4-sections.txt33
-rw-r--r--libsoup/libsoup-2.4.sym5
-rw-r--r--libsoup/soup-cache.c2
-rw-r--r--libsoup/soup-cache.h4
-rw-r--r--libsoup/soup-request-data.c4
-rw-r--r--libsoup/soup-request-data.h4
-rw-r--r--libsoup/soup-request-file.c6
-rw-r--r--libsoup/soup-request-file.h4
-rw-r--r--libsoup/soup-request-http.c15
-rw-r--r--libsoup/soup-request-http.h4
-rw-r--r--libsoup/soup-request.c45
-rw-r--r--libsoup/soup-request.h5
-rw-r--r--libsoup/soup-requester.c213
-rw-r--r--libsoup/soup-requester.h6
-rw-r--r--libsoup/soup-session.c187
-rw-r--r--libsoup/soup-session.h21
-rw-r--r--libsoup/soup-types.h1
-rw-r--r--libsoup/soup.h5
-rw-r--r--po/POTFILES.in2
-rw-r--r--tests/coding-test.c26
-rw-r--r--tests/connection-test.c9
-rw-r--r--tests/misc-test.c34
-rw-r--r--tests/proxy-test.c7
-rw-r--r--tests/redirect-test.c8
-rw-r--r--tests/requester-test.c51
-rw-r--r--tests/timeout-test.c32
27 files changed, 380 insertions, 370 deletions
diff --git a/docs/reference/libsoup-2.4-docs.sgml b/docs/reference/libsoup-2.4-docs.sgml
index ae74c015..3f246767 100644
--- a/docs/reference/libsoup-2.4-docs.sgml
+++ b/docs/reference/libsoup-2.4-docs.sgml
@@ -19,6 +19,7 @@
<xi:include href="xml/soup-auth-domain.xml"/>
<xi:include href="xml/soup-auth-domain-basic.xml"/>
<xi:include href="xml/soup-auth-domain-digest.xml"/>
+ <xi:include href="xml/soup-cache.xml"/>
<xi:include href="xml/soup-cookie.xml"/>
<xi:include href="xml/soup-message.xml"/>
<xi:include href="xml/soup-message-headers.xml"/>
@@ -26,6 +27,11 @@
<xi:include href="xml/soup-method.xml"/>
<xi:include href="xml/soup-misc.xml"/>
<xi:include href="xml/soup-multipart.xml"/>
+ <xi:include href="xml/soup-multipart-input-stream.xml"/>
+ <xi:include href="xml/soup-request.xml"/>
+ <xi:include href="xml/soup-request-http.xml"/>
+ <xi:include href="xml/soup-request-file.xml"/>
+ <xi:include href="xml/soup-request-data.xml"/>
<xi:include href="xml/soup-server.xml"/>
<xi:include href="xml/soup-session.xml"/>
<xi:include href="xml/soup-session-async.xml"/>
@@ -67,17 +73,6 @@
<xi:include href="xml/soup-socket.xml"/>
</chapter>
- <chapter>
- <title>Experimental streaming API</title>
- <xi:include href="xml/soup-requester.xml"/>
- <xi:include href="xml/soup-request.xml"/>
- <xi:include href="xml/soup-request-http.xml"/>
- <xi:include href="xml/soup-request-file.xml"/>
- <xi:include href="xml/soup-request-data.xml"/>
- <xi:include href="xml/soup-cache.xml"/>
- <xi:include href="xml/soup-multipart-input-stream.xml"/>
- </chapter>
-
<index>
<title>Index</title>
</index>
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index 81f4b77e..237d3f06 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -386,11 +386,17 @@ SoupAddressClass
<TITLE>SoupSession</TITLE>
SoupSession
<SUBSECTION>
+soup_session_request
+soup_session_request_uri
+SoupRequestError
+SOUP_REQUEST_ERROR
+<SUBSECTION>
SoupSessionCallback
soup_session_queue_message
soup_session_requeue_message
soup_session_send_message
soup_session_cancel_message
+<SUBSECTION>
soup_session_prefetch_dns
soup_session_prepare_for_uri
soup_session_abort
@@ -410,6 +416,7 @@ soup_session_remove_feature_by_type
soup_session_get_features
soup_session_get_feature
soup_session_get_feature_for_message
+soup_session_has_feature
<SUBSECTION>
SOUP_SESSION_PROXY_URI
SOUP_SESSION_MAX_CONNS
@@ -440,6 +447,8 @@ SOUP_SESSION_GET_CLASS
SOUP_TYPE_SESSION
SoupSessionClass
soup_session_get_type
+soup_request_error_get_type
+soup_request_error_quark
<SUBSECTION Private>
SoupConnection
SoupConnectionState
@@ -1090,30 +1099,6 @@ SOUP_IS_PROXY_RESOLVER_DEFAULT_CLASS
</SECTION>
<SECTION>
-<FILE>soup-requester</FILE>
-<TITLE>SoupRequester</TITLE>
-SoupRequester
-soup_requester_new
-soup_requester_request
-soup_requester_request_uri
-<SUBSECTION>
-SoupRequesterError
-SOUP_REQUESTER_ERROR
-<SUBSECTION Standard>
-soup_requester_get_type
-SoupRequesterClass
-SoupRequesterPrivate
-SOUP_TYPE_REQUESTER
-SOUP_REQUESTER
-SOUP_REQUESTER_CLASS
-SOUP_REQUESTER_GET_CLASS
-SOUP_IS_REQUESTER
-SOUP_IS_REQUESTER_CLASS
-<SUBSECTION Private>
-soup_requester_error_quark
-</SECTION>
-
-<SECTION>
<FILE>soup-request</FILE>
<TITLE>SoupRequest</TITLE>
SoupRequest
diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym
index 62cb933e..24dcc17d 100644
--- a/libsoup/libsoup-2.4.sym
+++ b/libsoup/libsoup-2.4.sym
@@ -316,6 +316,8 @@ soup_requester_get_type
soup_requester_new
soup_requester_request
soup_requester_request_uri
+soup_request_error_get_type
+soup_request_error_quark
soup_request_file_get_file
soup_request_file_get_type
soup_request_get_content_length
@@ -362,6 +364,7 @@ soup_session_get_feature
soup_session_get_feature_for_message
soup_session_get_features
soup_session_get_type
+soup_session_has_feature
soup_session_pause_message
soup_session_prefetch_dns
soup_session_prepare_for_uri
@@ -369,6 +372,8 @@ soup_session_queue_message
soup_session_redirect_message
soup_session_remove_feature
soup_session_remove_feature_by_type
+soup_session_request
+soup_session_request_uri
soup_session_requeue_message
soup_session_send_message
soup_session_sync_get_type
diff --git a/libsoup/soup-cache.c b/libsoup/soup-cache.c
index 50ea5928..24a4b2c6 100644
--- a/libsoup/soup-cache.c
+++ b/libsoup/soup-cache.c
@@ -31,8 +31,6 @@
#include <string.h>
-#define LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-cache.h"
#include "soup-cache-private.h"
#include "soup.h"
diff --git a/libsoup/soup-cache.h b/libsoup/soup-cache.h
index 64dcb787..ce19b5e1 100644
--- a/libsoup/soup-cache.h
+++ b/libsoup/soup-cache.h
@@ -23,8 +23,6 @@
#ifndef SOUP_CACHE_H
#define SOUP_CACHE_H 1
-#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include <libsoup/soup-types.h>
#include <gio/gio.h>
@@ -100,7 +98,5 @@ guint soup_cache_get_max_size (SoupCache *cache);
G_END_DECLS
-#endif /* LIBSOUP_USE_UNSTABLE_REQUEST_API */
-
#endif /* SOUP_CACHE_H */
diff --git a/libsoup/soup-request-data.c b/libsoup/soup-request-data.c
index 933d7522..0ff30c94 100644
--- a/libsoup/soup-request-data.c
+++ b/libsoup/soup-request-data.c
@@ -25,9 +25,7 @@
#include <config.h>
#endif
-#include <glib/gi18n-lib.h>
-
-#define LIBSOUP_USE_UNSTABLE_REQUEST_API
+#include <string.h>
#include "soup-request-data.h"
#include "soup.h"
diff --git a/libsoup/soup-request-data.h b/libsoup/soup-request-data.h
index f750b048..929c5908 100644
--- a/libsoup/soup-request-data.h
+++ b/libsoup/soup-request-data.h
@@ -22,8 +22,6 @@
#ifndef SOUP_REQUEST_DATA_H
#define SOUP_REQUEST_DATA_H 1
-#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-request.h"
G_BEGIN_DECLS
@@ -52,6 +50,4 @@ GType soup_request_data_get_type (void);
G_END_DECLS
-#endif /* LIBSOUP_USE_UNSTABLE_REQUEST_API */
-
#endif /* SOUP_REQUEST_DATA_H */
diff --git a/libsoup/soup-request-file.c b/libsoup/soup-request-file.c
index 22642f47..a71827bb 100644
--- a/libsoup/soup-request-file.c
+++ b/libsoup/soup-request-file.c
@@ -25,10 +25,6 @@
#include <config.h>
#endif
-#include <glib/gi18n-lib.h>
-
-#define LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-request-file.h"
#include "soup.h"
#include "soup-directory-input-stream.h"
@@ -281,7 +277,7 @@ soup_request_file_class_init (SoupRequestFileClass *request_file_class)
*
* Return value: (transfer full): a #GFile corresponding to @file
*
- * Since: 2.34
+ * Since: 2.40
*/
GFile *
soup_request_file_get_file (SoupRequestFile *file)
diff --git a/libsoup/soup-request-file.h b/libsoup/soup-request-file.h
index e86c5978..df2cbab1 100644
--- a/libsoup/soup-request-file.h
+++ b/libsoup/soup-request-file.h
@@ -22,8 +22,6 @@
#ifndef SOUP_REQUEST_FILE_H
#define SOUP_REQUEST_FILE_H 1
-#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-request.h"
G_BEGIN_DECLS
@@ -55,6 +53,4 @@ GFile *soup_request_file_get_file (SoupRequestFile *file);
G_END_DECLS
-#endif /* LIBSOUP_USE_UNSTABLE_REQUEST_API */
-
#endif /* SOUP_REQUEST_FILE_H */
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index d817cd08..96ba251b 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -27,8 +27,6 @@
#include <glib/gi18n-lib.h>
-#define LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-request-http.h"
#include "soup.h"
#include "soup-cache-private.h"
@@ -91,9 +89,11 @@ soup_request_http_send (SoupRequest *request,
GError **error)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupSession *session = soup_request_get_session (request);
+
+ g_return_val_if_fail (!SOUP_IS_SESSION_ASYNC (session), NULL);
- return soup_session_send_request (soup_request_get_session (request),
- http->priv->msg,
+ return soup_session_send_request (session, http->priv->msg,
cancellable, error);
}
@@ -187,17 +187,18 @@ soup_request_http_send_async (SoupRequest *request,
gpointer user_data)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupSession *session = soup_request_get_session (request);
GTask *task;
SendAsyncData *sadata;
GInputStream *stream;
- SoupSession *session;
SoupCache *cache;
+ g_return_if_fail (!SOUP_IS_SESSION_SYNC (session));
+
task = g_task_new (request, cancellable, callback, user_data);
sadata = g_slice_new0 (SendAsyncData);
g_task_set_task_data (task, sadata, (GDestroyNotify)free_send_async_data);
- session = soup_request_get_session (request);
cache = (SoupCache *)soup_session_get_feature (session, SOUP_TYPE_CACHE);
if (cache) {
@@ -320,7 +321,7 @@ soup_request_http_class_init (SoupRequestHTTPClass *request_http_class)
*
* Returns: (transfer full): a new reference to the #SoupMessage
*
- * Since: 2.34
+ * Since: 2.40
*/
SoupMessage *
soup_request_http_get_message (SoupRequestHTTP *http)
diff --git a/libsoup/soup-request-http.h b/libsoup/soup-request-http.h
index 750005af..bad4345c 100644
--- a/libsoup/soup-request-http.h
+++ b/libsoup/soup-request-http.h
@@ -22,8 +22,6 @@
#ifndef SOUP_REQUEST_HTTP_H
#define SOUP_REQUEST_HTTP_H 1
-#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-request.h"
G_BEGIN_DECLS
@@ -55,6 +53,4 @@ SoupMessage *soup_request_http_get_message (SoupRequestHTTP *http);
G_END_DECLS
-#endif /* LIBSOUP_USE_UNSTABLE_REQUEST_API */
-
#endif /* SOUP_REQUEST_HTTP_H */
diff --git a/libsoup/soup-request.c b/libsoup/soup-request.c
index dbc8361b..006a2537 100644
--- a/libsoup/soup-request.c
+++ b/libsoup/soup-request.c
@@ -27,8 +27,6 @@
#include <glib/gi18n-lib.h>
-#define LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include "soup-request.h"
#include "soup.h"
#include "soup-requester.h"
@@ -37,8 +35,8 @@
* SECTION:soup-request
* @short_description: Protocol-independent streaming request interface
*
- * A #SoupRequest is created by #SoupRequester, and represents a
- * request to retrieve a particular URI.
+ * A #SoupRequest is created by #SoupSession, and represents a request
+ * to retrieve a particular URI.
*/
/**
@@ -46,7 +44,7 @@
*
* A request to retrieve a particular URI.
*
- * Since: 2.34
+ * Since: 2.42
*/
static void soup_request_initable_interface_init (GInitableIface *initable_interface);
@@ -138,7 +136,7 @@ soup_request_initable_init (GInitable *initable,
gboolean ok;
if (!request->priv->uri) {
- g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_BAD_URI,
+ g_set_error (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI,
_("No URI provided"));
return FALSE;
}
@@ -148,7 +146,7 @@ soup_request_initable_init (GInitable *initable,
if (!ok && error && !*error) {
char *uri_string = soup_uri_to_string (request->priv->uri, FALSE);
- g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_BAD_URI,
+ g_set_error (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI,
_("Invalid '%s' URI: %s"),
request->priv->uri->scheme,
uri_string);
@@ -204,10 +202,13 @@ soup_request_default_send_finish (SoupRequest *request,
* Synchronously requests the URI pointed to by @request, and returns
* a #GInputStream that can be used to read its contents.
*
+ * Note that you cannot use this method with #SoupRequests attached to
+ * a #SoupSessionAsync.
+ *
* Return value: (transfer full): a #GInputStream that can be used to
* read from the URI pointed to by @request.
*
- * Since: 2.34
+ * Since: 2.42
*/
GInputStream *
soup_request_send (SoupRequest *request,
@@ -228,7 +229,10 @@ soup_request_send (SoupRequest *request,
* Begins an asynchronously request for the URI pointed to by
* @request.
*
- * Since: 2.34
+ * Note that you cannot use this method with #SoupRequests attached to
+ * a #SoupSessionSync.
+ *
+ * Since: 2.42
*/
void
soup_request_send_async (SoupRequest *request,
@@ -251,7 +255,7 @@ soup_request_send_async (SoupRequest *request,
* Return value: (transfer full): a #GInputStream that can be used to
* read from the URI pointed to by @request.
*
- * Since: 2.34
+ * Since: 2.42
*/
GInputStream *
soup_request_send_finish (SoupRequest *request,
@@ -307,7 +311,7 @@ soup_request_initable_interface_init (GInitableIface *initable_interface)
*
* Return value: (transfer none): @request's URI
*
- * Since: 2.34
+ * Since: 2.42
*/
SoupURI *
soup_request_get_uri (SoupRequest *request)
@@ -323,7 +327,7 @@ soup_request_get_uri (SoupRequest *request)
*
* Return value: (transfer none): @request's #SoupSession
*
- * Since: 2.34
+ * Since: 2.42
*/
SoupSession *
soup_request_get_session (SoupRequest *request)
@@ -335,12 +339,14 @@ soup_request_get_session (SoupRequest *request)
* soup_request_get_content_length:
* @request: a #SoupRequest
*
- * Gets the length of the data represented by @request.
+ * Gets the length of the data represented by @request. For most
+ * request types, this will not be known until after you call
+ * soup_request_send() or soup_request_send_finish().
*
* Return value: the length of the data represented by @request,
* or -1 if not known.
*
- * Since: 2.34
+ * Since: 2.42
*/
goffset
soup_request_get_content_length (SoupRequest *request)
@@ -352,14 +358,17 @@ soup_request_get_content_length (SoupRequest *request)
* soup_request_get_content_type:
* @request: a #SoupRequest
*
- * Gets the type of the data represented by @request. As in the
- * HTTP Content-Type header, this may include parameters after
- * the MIME type.
+ * Gets the type of the data represented by @request. For most request
+ * types, this will not be known until after you call
+ * soup_request_send() or soup_request_send_finish().
+ *
+ * As in the HTTP Content-Type header, this may include parameters
+ * after the MIME type.
*
* Return value: the type of the data represented by @request,
* or %NULL if not known.
*
- * Since: 2.34
+ * Since: 2.42
*/
const char *
soup_request_get_content_type (SoupRequest *request)
diff --git a/libsoup/soup-request.h b/libsoup/soup-request.h
index bc6cdffe..84ad6d6b 100644
--- a/libsoup/soup-request.h
+++ b/libsoup/soup-request.h
@@ -22,8 +22,6 @@
#ifndef SOUP_REQUEST_H
#define SOUP_REQUEST_H 1
-#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
-
#include <gio/gio.h>
#include <libsoup/soup-types.h>
@@ -37,7 +35,6 @@ G_BEGIN_DECLS
#define SOUP_IS_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_REQUEST))
#define SOUP_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_REQUEST, SoupRequestClass))
-typedef struct _SoupRequest SoupRequest;
typedef struct _SoupRequestPrivate SoupRequestPrivate;
typedef struct _SoupRequestClass SoupRequestClass;
@@ -103,6 +100,4 @@ const char *soup_request_get_content_type (SoupRequest *request);
G_END_DECLS
-#endif /* LIBSOUP_USE_UNSTABLE_REQUEST_API */
-
#endif /* SOUP_REQUEST_H */
diff --git a/libsoup/soup-requester.c b/libsoup/soup-requester.c
index 281ebb17..ce679821 100644
--- a/libsoup/soup-requester.c
+++ b/libsoup/soup-requester.c
@@ -22,22 +22,18 @@
#include "config.h"
-#include <glib/gi18n-lib.h>
-
#define LIBSOUP_USE_UNSTABLE_REQUEST_API
#include "soup-requester.h"
#include "soup.h"
-#include "soup-request-data.h"
-#include "soup-request-file.h"
-#include "soup-request-http.h"
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static SoupSessionFeatureInterface *soup_requester_default_feature_interface;
static void soup_requester_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data);
struct _SoupRequesterPrivate {
SoupSession *session;
- GHashTable *request_types;
};
G_DEFINE_TYPE_WITH_CODE (SoupRequester, soup_requester, G_TYPE_OBJECT,
@@ -47,44 +43,19 @@ G_DEFINE_TYPE_WITH_CODE (SoupRequester, soup_requester, G_TYPE_OBJECT,
static void
soup_requester_init (SoupRequester *requester)
{
- SoupSessionFeature *feature;
-
requester->priv = G_TYPE_INSTANCE_GET_PRIVATE (requester,
SOUP_TYPE_REQUESTER,
SoupRequesterPrivate);
-
- requester->priv->request_types = g_hash_table_new (soup_str_case_hash,
- soup_str_case_equal);
-
- feature = SOUP_SESSION_FEATURE (requester);
- soup_session_feature_add_feature (feature, SOUP_TYPE_REQUEST_HTTP);
- soup_session_feature_add_feature (feature, SOUP_TYPE_REQUEST_FILE);
- soup_session_feature_add_feature (feature, SOUP_TYPE_REQUEST_DATA);
-}
-
-static void
-soup_requester_finalize (GObject *object)
-{
- SoupRequester *requester = SOUP_REQUESTER (object);
-
- g_hash_table_destroy (requester->priv->request_types);
-
- G_OBJECT_CLASS (soup_requester_parent_class)->finalize (object);
}
static void
soup_requester_class_init (SoupRequesterClass *requester_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (requester_class);
-
g_type_class_add_private (requester_class, sizeof (SoupRequesterPrivate));
-
- /* virtual method override */
- object_class->finalize = soup_requester_finalize;
}
static void
-attach (SoupSessionFeature *feature, SoupSession *session)
+soup_requester_attach (SoupSessionFeature *feature, SoupSession *session)
{
SoupRequester *requester = SOUP_REQUESTER (feature);
@@ -94,7 +65,7 @@ attach (SoupSessionFeature *feature, SoupSession *session)
}
static void
-detach (SoupSessionFeature *feature, SoupSession *session)
+soup_requester_detach (SoupSessionFeature *feature, SoupSession *session)
{
SoupRequester *requester = SOUP_REQUESTER (feature);
@@ -103,66 +74,6 @@ detach (SoupSessionFeature *feature, SoupSession *session)
soup_requester_default_feature_interface->detach (feature, session);
}
-static gboolean
-add_feature (SoupSessionFeature *feature, GType type)
-{
- SoupRequester *requester = SOUP_REQUESTER (feature);
- SoupRequestClass *request_class;
- int i;
-
- if (!g_type_is_a (type, SOUP_TYPE_REQUEST))
- return FALSE;
-
- request_class = g_type_class_ref (type);
- for (i = 0; request_class->schemes[i]; i++) {
- g_hash_table_insert (requester->priv->request_types,
- (char *)request_class->schemes[i],
- GSIZE_TO_POINTER (type));
- }
- return TRUE;
-}
-
-static gboolean
-remove_feature (SoupSessionFeature *feature, GType type)
-{
- SoupRequester *requester = SOUP_REQUESTER (feature);
- SoupRequestClass *request_class;
- int i, orig_size;
-
- if (!g_type_is_a (type, SOUP_TYPE_REQUEST))
- return FALSE;
-
- request_class = g_type_class_peek (type);
- if (!request_class)
- return FALSE;
-
- orig_size = g_hash_table_size (requester->priv->request_types);
- for (i = 0; request_class->schemes[i]; i++) {
- g_hash_table_remove (requester->priv->request_types,
- request_class->schemes[i]);
- }
-
- return g_hash_table_size (requester->priv->request_types) != orig_size;
-}
-
-static gboolean
-has_feature (SoupSessionFeature *feature, GType type)
-{
- SoupRequester *requester = SOUP_REQUESTER (feature);
- GHashTableIter iter;
- gpointer key, value;
-
- if (!g_type_is_a (type, SOUP_TYPE_REQUEST))
- return FALSE;
-
- g_hash_table_iter_init (&iter, requester->priv->request_types);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- if (value == GSIZE_TO_POINTER (type))
- return TRUE;
- }
- return FALSE;
-}
-
static void
soup_requester_session_feature_init (SoupSessionFeatureInterface *feature_interface,
gpointer interface_data)
@@ -170,115 +81,65 @@ soup_requester_session_feature_init (SoupSessionFeatureInterface *feature_interf
soup_requester_default_feature_interface =
g_type_default_interface_peek (SOUP_TYPE_SESSION_FEATURE);
- feature_interface->attach = attach;
- feature_interface->detach = detach;
- feature_interface->add_feature = add_feature;
- feature_interface->remove_feature = remove_feature;
- feature_interface->has_feature = has_feature;
+ feature_interface->attach = soup_requester_attach;
+ feature_interface->detach = soup_requester_detach;
}
-/**
- * soup_requester_new:
- *
- * Creates a new #SoupRequester object, which can be added to
- * a #SoupSession with soup_session_add_feature().
- *
- * Return value: the new #SoupRequester
- *
- * Since: 2.34
- */
SoupRequester *
soup_requester_new (void)
{
return g_object_new (SOUP_TYPE_REQUESTER, NULL);
}
-/**
- * soup_requester_request:
- * @requester: a #SoupRequester
- * @uri_string: a URI, in string form
- * @error: return location for a #GError, or %NULL
- *
- * Creates a #SoupRequest for retrieving @uri_string.
- *
- * Return value: (transfer full): a new #SoupRequest, or
- * %NULL on error.
- *
- * Since: 2.34
- */
+static void
+translate_error (GError *error)
+{
+ if (error->domain != SOUP_REQUEST_ERROR)
+ return;
+
+ error->domain = SOUP_REQUESTER_ERROR;
+ if (error->code == SOUP_REQUEST_ERROR_BAD_URI)
+ error->code = SOUP_REQUESTER_ERROR_BAD_URI;
+ else if (error->code == SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME)
+ error->code = SOUP_REQUESTER_ERROR_UNSUPPORTED_URI_SCHEME;
+ else
+ g_warn_if_reached ();
+}
+
SoupRequest *
soup_requester_request (SoupRequester *requester, const char *uri_string,
GError **error)
{
- SoupURI *uri;
SoupRequest *req;
- uri = soup_uri_new (uri_string);
- if (!uri) {
- g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_BAD_URI,
- _("Could not parse URI '%s'"), uri_string);
- return NULL;
- }
+ g_return_val_if_fail (SOUP_IS_REQUESTER (requester), NULL);
+
+ req = soup_session_request (requester->priv->session,
+ uri_string, error);
+ if (req || !error)
+ return req;
- req = soup_requester_request_uri (requester, uri, error);
- soup_uri_free (uri);
- return req;
+ translate_error (*error);
+ return NULL;
}
-/**
- * soup_requester_request_uri:
- * @requester: a #SoupRequester
- * @uri: a #SoupURI representing the URI to retrieve
- * @error: return location for a #GError, or %NULL
- *
- * Creates a #SoupRequest for retrieving @uri.
- *
- * Return value: (transfer full): a new #SoupRequest, or
- * %NULL on error.
- *
- * Since: 2.34
- */
SoupRequest *
soup_requester_request_uri (SoupRequester *requester, SoupURI *uri,
GError **error)
{
- GType request_type;
+ SoupRequest *req;
g_return_val_if_fail (SOUP_IS_REQUESTER (requester), NULL);
- request_type = (GType)GPOINTER_TO_SIZE (g_hash_table_lookup (requester->priv->request_types, uri->scheme));
- if (!request_type) {
- g_set_error (error, SOUP_REQUESTER_ERROR,
- SOUP_REQUESTER_ERROR_UNSUPPORTED_URI_SCHEME,
- _("Unsupported URI scheme '%s'"), uri->scheme);
- return NULL;
- }
+ req = soup_session_request_uri (requester->priv->session,
+ uri, error);
+ if (req || !error)
+ return req;
- return g_initable_new (request_type, NULL, error,
- "uri", uri,
- "session", requester->priv->session,
- NULL);
+ translate_error (*error);
+ return NULL;
}
-/**
- * SOUP_REQUESTER_ERROR:
- *
- * A #GError domain for #SoupRequester errors. Used with
- * #SoupRequesterError.
- *
- * Since: 2.34
- */
-/**
- * SoupRequesterError:
- * @SOUP_REQUESTER_ERROR_BAD_URI: the URI could not be parsed
- * @SOUP_REQUESTER_ERROR_UNSUPPORTED_URI_SCHEME: the URI scheme is not
- * supported by this #SoupRequester
- *
- * A #SoupRequester error.
- *
- * Since: 2.34
- */
-
GQuark
soup_requester_error_quark (void)
{
@@ -287,3 +148,5 @@ soup_requester_error_quark (void)
error = g_quark_from_static_string ("soup_requester_error_quark");
return error;
}
+
+G_GNUC_END_IGNORE_DEPRECATIONS
diff --git a/libsoup/soup-requester.h b/libsoup/soup-requester.h
index 3bf249c8..06355131 100644
--- a/libsoup/soup-requester.h
+++ b/libsoup/soup-requester.h
@@ -24,7 +24,6 @@
#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
#include <libsoup/soup-types.h>
-#include <libsoup/soup-request.h>
G_BEGIN_DECLS
@@ -49,22 +48,27 @@ typedef struct {
} SoupRequesterClass;
SOUP_AVAILABLE_IN_2_34
+SOUP_DEPRECATED_IN_2_42
GType soup_requester_get_type (void);
SOUP_AVAILABLE_IN_2_34
+SOUP_DEPRECATED_IN_2_42
SoupRequester *soup_requester_new (void);
SOUP_AVAILABLE_IN_2_34
+SOUP_DEPRECATED_IN_2_42_FOR(soup_session_request)
SoupRequest *soup_requester_request (SoupRequester *requester,
const char *uri_string,
GError **error);
SOUP_AVAILABLE_IN_2_34
+SOUP_DEPRECATED_IN_2_42_FOR(soup_session_request_uri)
SoupRequest *soup_requester_request_uri (SoupRequester *requester,
SoupURI *uri,
GError **error);
SOUP_AVAILABLE_IN_2_34
+SOUP_DEPRECATED_IN_2_42_FOR(SOUP_REQUEST_ERROR)
GQuark soup_requester_error_quark (void);
#define SOUP_REQUESTER_ERROR soup_requester_error_quark ()
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index eb26e8cb..20d1c062 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -78,6 +78,7 @@ static gboolean soup_host_uri_equal (gconstpointer v1, gconstpointer v2);
typedef struct {
SoupSession *session;
+ gboolean disposed;
GTlsDatabase *tlsdb;
char *ssl_ca_file;
@@ -116,7 +117,7 @@ typedef struct {
char **http_aliases, **https_aliases;
- gboolean disposed;
+ GHashTable *request_types;
} SoupSessionPrivate;
#define SOUP_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_SESSION, SoupSessionPrivate))
@@ -232,6 +233,12 @@ soup_session_init (SoupSession *session)
priv->http_aliases = g_new (char *, 2);
priv->http_aliases[0] = (char *)g_intern_string ("*");
priv->http_aliases[1] = NULL;
+
+ priv->request_types = g_hash_table_new (soup_str_case_hash,
+ soup_str_case_equal);
+ soup_session_add_feature_by_type (session, SOUP_TYPE_REQUEST_HTTP);
+ soup_session_add_feature_by_type (session, SOUP_TYPE_REQUEST_FILE);
+ soup_session_add_feature_by_type (session, SOUP_TYPE_REQUEST_DATA);
}
static GObject *
@@ -322,6 +329,8 @@ soup_session_finalize (GObject *object)
g_free (priv->http_aliases);
g_free (priv->https_aliases);
+ g_hash_table_destroy (priv->request_types);
+
G_OBJECT_CLASS (soup_session_parent_class)->finalize (object);
}
@@ -2359,10 +2368,10 @@ soup_session_add_feature (SoupSession *session, SoupSessionFeature *feature)
* adds it to @session as with soup_session_add_feature(). You can use
* this when you don't need to customize the new feature in any way.
*
- * If @feature_type is not a #SoupSessionFeature type, this gives
- * each existing feature on @session the chance to accept @feature_type
- * as a "subfeature". This can be used to add new #SoupAuth types,
- * for instance.
+ * If @feature_type is not a #SoupSessionFeature type, this gives each
+ * existing feature on @session the chance to accept @feature_type as
+ * a "subfeature". This can be used to add new #SoupAuth or
+ * #SoupRequest types, for instance.
*
* You can also add a feature to the session at construct time by
* using the %SOUP_SESSION_ADD_FEATURE_BY_TYPE property.
@@ -2372,16 +2381,29 @@ soup_session_add_feature (SoupSession *session, SoupSessionFeature *feature)
void
soup_session_add_feature_by_type (SoupSession *session, GType feature_type)
{
+ SoupSessionPrivate *priv;
+
g_return_if_fail (SOUP_IS_SESSION (session));
+ priv = SOUP_SESSION_GET_PRIVATE (session);
+
if (g_type_is_a (feature_type, SOUP_TYPE_SESSION_FEATURE)) {
SoupSessionFeature *feature;
feature = g_object_new (feature_type, NULL);
soup_session_add_feature (session, feature);
g_object_unref (feature);
+ } else if (g_type_is_a (feature_type, SOUP_TYPE_REQUEST)) {
+ SoupRequestClass *request_class;
+ int i;
+
+ request_class = g_type_class_ref (feature_type);
+ for (i = 0; request_class->schemes[i]; i++) {
+ g_hash_table_insert (priv->request_types,
+ (char *)request_class->schemes[i],
+ GSIZE_TO_POINTER (feature_type));
+ }
} else {
- SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
GSList *f;
for (f = priv->features; f; f = f->next) {
@@ -2447,6 +2469,17 @@ soup_session_remove_feature_by_type (SoupSession *session, GType feature_type)
goto restart;
}
}
+ } else if (g_type_is_a (feature_type, SOUP_TYPE_REQUEST)) {
+ SoupRequestClass *request_class;
+ int i;
+
+ request_class = g_type_class_peek (feature_type);
+ if (!request_class)
+ return;
+ for (i = 0; request_class->schemes[i]; i++) {
+ g_hash_table_remove (priv->request_types,
+ request_class->schemes[i]);
+ }
} else {
for (f = priv->features; f; f = f->next) {
if (soup_session_feature_remove_feature (f->data, feature_type))
@@ -2457,6 +2490,49 @@ soup_session_remove_feature_by_type (SoupSession *session, GType feature_type)
}
/**
+ * soup_session_has_feature:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of the class of features to check for
+ *
+ * Tests if @session has at a feature of type @feature_type (which can
+ * be the type of either a #SoupSessionFeature, or else a subtype of
+ * some class managed by another feature, such as #SoupAuth or
+ * #SoupRequest).
+ *
+ * Return value: %TRUE or %FALSE
+ *
+ * Since: 2.42
+ **/
+gboolean
+soup_session_has_feature (SoupSession *session,
+ GType feature_type)
+{
+ SoupSessionPrivate *priv;
+ GSList *f;
+
+ g_return_val_if_fail (SOUP_IS_SESSION (session), FALSE);
+
+ priv = SOUP_SESSION_GET_PRIVATE (session);
+
+ if (g_type_is_a (feature_type, SOUP_TYPE_SESSION_FEATURE)) {
+ for (f = priv->features; f; f = f->next) {
+ if (G_TYPE_CHECK_INSTANCE_TYPE (f->data, feature_type))
+ return TRUE;
+ }
+ } else if (g_type_is_a (feature_type, SOUP_TYPE_REQUEST)) {
+ return g_hash_table_lookup (priv->request_types,
+ GSIZE_TO_POINTER (feature_type)) != NULL;
+ } else {
+ for (f = priv->features; f; f = f->next) {
+ if (soup_session_feature_has_feature (f->data, feature_type))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
* soup_session_get_features:
* @session: a #SoupSession
* @feature_type: the #GType of the class of features to get
@@ -3655,3 +3731,102 @@ soup_session_send_request (SoupSession *session,
soup_message_queue_item_unref (item);
return stream;
}
+
+/**
+ * soup_session_request:
+ * @session: a #SoupSession
+ * @uri_string: a URI, in string form
+ * @error: return location for a #GError, or %NULL
+ *
+ * Creates a #SoupRequest for retrieving @uri_string.
+ *
+ * Return value: (transfer full): a new #SoupRequest, or
+ * %NULL on error.
+ *
+ * Since: 2.42
+ */
+SoupRequest *
+soup_session_request (SoupSession *session, const char *uri_string,
+ GError **error)
+{
+ SoupURI *uri;
+ SoupRequest *req;
+
+ uri = soup_uri_new (uri_string);
+ if (!uri) {
+ g_set_error (error, SOUP_REQUEST_ERROR,
+ SOUP_REQUEST_ERROR_BAD_URI,
+ _("Could not parse URI '%s'"), uri_string);
+ return NULL;
+ }
+
+ req = soup_session_request_uri (session, uri, error);
+ soup_uri_free (uri);
+ return req;
+}
+
+/**
+ * soup_session_request_uri:
+ * @session: a #SoupSession
+ * @uri: a #SoupURI representing the URI to retrieve
+ * @error: return location for a #GError, or %NULL
+ *
+ * Creates a #SoupRequest for retrieving @uri.
+ *
+ * Return value: (transfer full): a new #SoupRequest, or
+ * %NULL on error.
+ *
+ * Since: 2.42
+ */
+SoupRequest *
+soup_session_request_uri (SoupSession *session, SoupURI *uri,
+ GError **error)
+{
+ SoupSessionPrivate *priv;
+ GType request_type;
+
+ g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
+
+ priv = SOUP_SESSION_GET_PRIVATE (session);
+
+ request_type = (GType)GPOINTER_TO_SIZE (g_hash_table_lookup (priv->request_types, uri->scheme));
+ if (!request_type) {
+ g_set_error (error, SOUP_REQUEST_ERROR,
+ SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME,
+ _("Unsupported URI scheme '%s'"), uri->scheme);
+ return NULL;
+ }
+
+ return g_initable_new (request_type, NULL, error,
+ "uri", uri,
+ "session", session,
+ NULL);
+}
+
+/**
+ * SOUP_REQUEST_ERROR:
+ *
+ * A #GError domain for #SoupRequest-related errors. Used with
+ * #SoupRequestError.
+ *
+ * Since: 2.42
+ */
+/**
+ * SoupRequestError:
+ * @SOUP_REQUEST_ERROR_BAD_URI: the URI could not be parsed
+ * @SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME: the URI scheme is not
+ * supported by this #SoupSession
+ *
+ * A #SoupRequest error.
+ *
+ * Since: 2.42
+ */
+
+GQuark
+soup_request_error_quark (void)
+{
+ static GQuark error;
+ if (!error)
+ error = g_quark_from_static_string ("soup_request_error_quark");
+ return error;
+}
diff --git a/libsoup/soup-session.h b/libsoup/soup-session.h
index 4dd79ffd..acc12a9a 100644
--- a/libsoup/soup-session.h
+++ b/libsoup/soup-session.h
@@ -134,6 +134,9 @@ void soup_session_remove_feature (SoupSession *ses
SOUP_AVAILABLE_IN_2_24
void soup_session_remove_feature_by_type (SoupSession *session,
GType feature_type);
+SOUP_AVAILABLE_IN_2_42
+gboolean soup_session_has_feature (SoupSession *session,
+ GType feature_type);
SOUP_AVAILABLE_IN_2_26
GSList *soup_session_get_features (SoupSession *session,
GType feature_type);
@@ -145,6 +148,24 @@ SoupSessionFeature *soup_session_get_feature_for_message(SoupSession *ses
GType feature_type,
SoupMessage *msg);
+SOUP_AVAILABLE_IN_2_42
+SoupRequest *soup_session_request (SoupSession *session,
+ const char *uri_string,
+ GError **error);
+SOUP_AVAILABLE_IN_2_42
+SoupRequest *soup_session_request_uri (SoupSession *session,
+ SoupURI *uri,
+ GError **error);
+
+SOUP_AVAILABLE_IN_2_42
+GQuark soup_request_error_quark (void);
+#define SOUP_REQUEST_ERROR soup_request_error_quark ()
+
+typedef enum {
+ SOUP_REQUEST_ERROR_BAD_URI,
+ SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME
+} SoupRequestError;
+
G_END_DECLS
#endif /* SOUP_SESSION_H */
diff --git a/libsoup/soup-types.h b/libsoup/soup-types.h
index 77e5425b..4134b834 100644
--- a/libsoup/soup-types.h
+++ b/libsoup/soup-types.h
@@ -20,6 +20,7 @@ typedef struct _SoupCookie SoupCookie;
typedef struct _SoupCookieJar SoupCookieJar;
typedef struct _SoupDate SoupDate;
typedef struct _SoupMessage SoupMessage;
+typedef struct _SoupRequest SoupRequest;
typedef struct _SoupServer SoupServer;
typedef struct _SoupSession SoupSession;
typedef struct _SoupSessionAsync SoupSessionAsync;
diff --git a/libsoup/soup.h b/libsoup/soup.h
index 2a2b051d..f99f3e68 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -15,6 +15,7 @@ extern "C" {
#include <libsoup/soup-auth-domain.h>
#include <libsoup/soup-auth-domain-basic.h>
#include <libsoup/soup-auth-domain-digest.h>
+#include <libsoup/soup-cache.h>
#include <libsoup/soup-content-decoder.h>
#include <libsoup/soup-content-sniffer.h>
#include <libsoup/soup-cookie.h>
@@ -34,6 +35,10 @@ extern "C" {
#include <libsoup/soup-proxy-resolver.h>
#include <libsoup/soup-proxy-resolver-default.h>
#include <libsoup/soup-proxy-uri-resolver.h>
+#include <libsoup/soup-request.h>
+#include <libsoup/soup-request-data.h>
+#include <libsoup/soup-request-file.h>
+#include <libsoup/soup-request-http.h>
#include <libsoup/soup-server.h>
#include <libsoup/soup-session-async.h>
#include <libsoup/soup-session-feature.h>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a05aa79b..ba5d82dd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,5 +2,5 @@ libsoup/soup-body-input-stream.c
libsoup/soup-converter-wrapper.c
libsoup/soup-message-io.c
libsoup/soup-request.c
-libsoup/soup-requester.c
+libsoup/soup-session.c
libsoup/soup-tld.c
diff --git a/tests/coding-test.c b/tests/coding-test.c
index cd7321ed..2718353b 100644
--- a/tests/coding-test.c
+++ b/tests/coding-test.c
@@ -397,7 +397,6 @@ static void
do_coding_req_test (void)
{
SoupSession *session;
- SoupRequester *requester;
SoupRequest *req;
SoupMessage *msg;
SoupURI *uri;
@@ -407,21 +406,19 @@ do_coding_req_test (void)
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
uri = soup_uri_new_with_base (base_uri, "/mbox");
/* Plain text data, no claim */
debug_printf (1, " GET /mbox, plain\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
plain = do_single_coding_req_test (req, NULL, "text/plain", EXPECT_NOT_DECODED);
g_object_unref (req);
/* Plain text data, claim gzip */
debug_printf (1, " GET /mbox, Accept-Encoding: gzip\n");
soup_session_add_feature_by_type (session, SOUP_TYPE_CONTENT_DECODER);
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
cmp = do_single_coding_req_test (req, "gzip", "text/plain", EXPECT_DECODED);
check_req_bodies (plain, cmp, "plain", "compressed");
g_byte_array_free (cmp, TRUE);
@@ -429,7 +426,7 @@ do_coding_req_test (void)
/* Plain text data, claim gzip w/ junk */
debug_printf (1, " GET /mbox, Accept-Encoding: gzip, plus trailing junk\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "trailing-junk");
@@ -441,7 +438,7 @@ do_coding_req_test (void)
/* Plain text data, claim gzip with server error */
debug_printf (1, " GET /mbox, Accept-Encoding: gzip, with server error\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "force-encode");
@@ -458,7 +455,7 @@ do_coding_req_test (void)
/* Plain text data, claim deflate */
debug_printf (1, " GET /mbox, Accept-Encoding: deflate\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "prefer-deflate-zlib");
@@ -470,7 +467,7 @@ do_coding_req_test (void)
/* Plain text data, claim deflate w/ junk */
debug_printf (1, " GET /mbox, Accept-Encoding: deflate, plus trailing junk\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "prefer-deflate-zlib, trailing-junk");
@@ -482,7 +479,7 @@ do_coding_req_test (void)
/* Plain text data, claim deflate with server error */
debug_printf (1, " GET /mbox, Accept-Encoding: deflate, with server error\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "force-encode, prefer-deflate-zlib");
@@ -494,7 +491,7 @@ do_coding_req_test (void)
/* Plain text data, claim deflate (no zlib headers)*/
debug_printf (1, " GET /mbox, Accept-Encoding: deflate (raw data)\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "prefer-deflate-raw");
@@ -506,7 +503,7 @@ do_coding_req_test (void)
/* Plain text data, claim deflate with server error */
debug_printf (1, " GET /mbox, Accept-Encoding: deflate (raw data), with server error\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "force-encode, prefer-deflate-raw");
@@ -528,7 +525,6 @@ do_coding_empty_test (void)
SoupSession *session;
SoupMessage *msg;
SoupURI *uri;
- SoupRequester *requester;
SoupRequest *req;
GByteArray *body;
@@ -537,9 +533,7 @@ do_coding_empty_test (void)
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
uri = soup_uri_new_with_base (base_uri, "/mbox");
debug_printf (1, " SoupMessage\n");
@@ -551,7 +545,7 @@ do_coding_empty_test (void)
g_object_unref (msg);
debug_printf (1, " SoupRequest\n");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
soup_message_headers_append (msg->request_headers,
"X-Test-Options", "empty");
diff --git a/tests/connection-test.c b/tests/connection-test.c
index 8050b3df..6b57f24d 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -299,7 +299,6 @@ do_timeout_test_for_session (SoupSession *session)
static void
do_timeout_req_test_for_session (SoupSession *session)
{
- SoupRequester *requester;
SoupRequest *req;
SoupMessage *msg;
GInputStream *stream;
@@ -308,17 +307,13 @@ do_timeout_req_test_for_session (SoupSession *session)
GError *error = NULL;
int i;
- requester = soup_requester_new ();
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (requester));
- g_object_unref (requester);
-
g_signal_connect (session, "request-started",
G_CALLBACK (request_started_socket_collector),
&sockets);
debug_printf (1, " First request\n");
timeout_uri = soup_uri_new_with_base (base_uri, "/timeout-persistent");
- req = soup_requester_request_uri (requester, timeout_uri, NULL);
+ req = soup_session_request_uri (session, timeout_uri, NULL);
soup_uri_free (timeout_uri);
stream = soup_test_request_send (req, NULL, &error);
@@ -346,7 +341,7 @@ do_timeout_req_test_for_session (SoupSession *session)
g_object_unref (req);
debug_printf (1, " Second request\n");
- req = soup_requester_request_uri (requester, base_uri, NULL);
+ req = soup_session_request_uri (session, base_uri, NULL);
stream = soup_test_request_send (req, NULL, &error);
if (!stream) {
diff --git a/tests/misc-test.c b/tests/misc-test.c
index b564f269..b243ce46 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -318,7 +318,6 @@ do_callback_unref_req_test (void)
SoupServer *bad_server;
SoupAddress *addr;
SoupSession *session;
- SoupRequester *requester;
SoupRequest *one, *two;
GMainLoop *loop;
char *bad_uri;
@@ -337,18 +336,15 @@ do_callback_unref_req_test (void)
g_object_unref (bad_server);
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
g_object_add_weak_pointer (G_OBJECT (session), (gpointer *)&session);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
-
loop = g_main_loop_new (NULL, TRUE);
- one = soup_requester_request (requester, bad_uri, NULL);
+ one = soup_session_request (session, bad_uri, NULL);
g_object_add_weak_pointer (G_OBJECT (one), (gpointer *)&one);
- two = soup_requester_request (requester, bad_uri, NULL);
+ two = soup_session_request (session, bad_uri, NULL);
g_object_add_weak_pointer (G_OBJECT (two), (gpointer *)&two);
g_free (bad_uri);
@@ -708,7 +704,6 @@ static void
do_early_abort_req_test (void)
{
SoupSession *session;
- SoupRequester *requester;
SoupRequest *req;
GMainContext *context;
GMainLoop *loop;
@@ -717,11 +712,9 @@ do_early_abort_req_test (void)
debug_printf (1, "\nAbort with pending connection (request api)\n");
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- req = soup_requester_request_uri (requester, base_uri, NULL);
+ req = soup_session_request_uri (session, base_uri, NULL);
context = g_main_context_default ();
loop = g_main_loop_new (context, TRUE);
@@ -735,11 +728,9 @@ do_early_abort_req_test (void)
soup_test_session_abort_unref (session);
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- req = soup_requester_request_uri (requester, base_uri, NULL);
+ req = soup_session_request_uri (session, base_uri, NULL);
g_signal_connect (session, "connection-created",
G_CALLBACK (ea_connection_created), NULL);
@@ -753,11 +744,9 @@ do_early_abort_req_test (void)
soup_test_session_abort_unref (session);
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- req = soup_requester_request_uri (requester, base_uri, NULL);
+ req = soup_session_request_uri (session, base_uri, NULL);
cancellable = g_cancellable_new ();
g_signal_connect (session, "request-started",
@@ -933,7 +922,7 @@ cancel_request_thread (gpointer cancellable)
}
static void
-do_cancel_while_reading_req_test_for_session (SoupRequester *requester)
+do_cancel_while_reading_req_test_for_session (SoupSession *session)
{
SoupRequest *req;
SoupURI *uri;
@@ -941,7 +930,7 @@ do_cancel_while_reading_req_test_for_session (SoupRequester *requester)
GError *error = NULL;
uri = soup_uri_new_with_base (base_uri, "/slow");
- req = soup_requester_request_uri (requester, uri, NULL);
+ req = soup_session_request_uri (session, uri, NULL);
soup_uri_free (uri);
cancellable = g_cancellable_new ();
@@ -975,25 +964,20 @@ static void
do_cancel_while_reading_req_test (void)
{
SoupSession *session;
- SoupRequester *requester;
debug_printf (1, "\nCancelling message while reading response (request api)\n");
debug_printf (1, " Async session\n");
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- do_cancel_while_reading_req_test_for_session (requester);
+ do_cancel_while_reading_req_test_for_session (session);
soup_test_session_abort_unref (session);
debug_printf (1, " Sync session\n");
session = soup_test_session_new (SOUP_TYPE_SESSION_SYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
NULL);
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- do_cancel_while_reading_req_test_for_session (requester);
+ do_cancel_while_reading_req_test_for_session (session);
soup_test_session_abort_unref (session);
}
diff --git a/tests/proxy-test.c b/tests/proxy-test.c
index 94e548a8..048acfa7 100644
--- a/tests/proxy-test.c
+++ b/tests/proxy-test.c
@@ -132,7 +132,6 @@ test_url_new_api (const char *url, int proxy, guint expected,
SoupSession *session;
SoupURI *proxy_uri;
SoupMessage *msg;
- SoupRequester *requester;
SoupRequest *request;
GInputStream *stream;
GError *error = NULL;
@@ -140,7 +139,7 @@ test_url_new_api (const char *url, int proxy, guint expected,
if (!tls_available && g_str_has_prefix (url, "https:"))
return;
- debug_printf (1, " GET (requester API) %s via %s%s\n", url, proxy_names[proxy],
+ debug_printf (1, " GET (request API) %s via %s%s\n", url, proxy_names[proxy],
close ? " (with Connection: close)" : "");
if (proxy == UNAUTH_PROXY && expected != SOUP_STATUS_FORBIDDEN)
expected = SOUP_STATUS_PROXY_UNAUTHORIZED;
@@ -150,7 +149,6 @@ test_url_new_api (const char *url, int proxy, guint expected,
*/
proxy_uri = soup_uri_new (proxies[proxy]);
session = soup_test_session_new (sync ? SOUP_TYPE_SESSION_SYNC : SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_PROXY_URI, proxy_uri,
NULL);
@@ -163,8 +161,7 @@ test_url_new_api (const char *url, int proxy, guint expected,
G_CALLBACK (set_close_on_connect), NULL);
}
- requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- request = soup_requester_request (requester, url, NULL);
+ request = soup_session_request (session, url, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
stream = soup_test_request_send (request, NULL, &error);
diff --git a/tests/redirect-test.c b/tests/redirect-test.c
index 3708d865..9adf5d5a 100644
--- a/tests/redirect-test.c
+++ b/tests/redirect-test.c
@@ -208,7 +208,6 @@ do_message_api_test (SoupSession *session, SoupURI *base_uri, int n)
static void
do_request_api_test (SoupSession *session, SoupURI *base_uri, int n)
{
- SoupRequester *requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
SoupURI *uri;
SoupRequest *req;
SoupMessage *msg;
@@ -226,7 +225,7 @@ do_request_api_test (SoupSession *session, SoupURI *base_uri, int n)
final_status = tests[n].final_status;
uri = soup_uri_new_with_base (base_uri, tests[n].requests[0].path);
- req = soup_requester_request_uri (requester, uri, &error);
+ req = soup_session_request_uri (session, uri, &error);
soup_uri_free (uri);
if (!req) {
debug_printf (1, " could not create request: %s\n",
@@ -315,7 +314,6 @@ do_redirect_tests (SoupURI *base_uri)
int n;
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
debug_printf (1, "Async session, SoupMessage\n");
@@ -326,9 +324,7 @@ do_redirect_tests (SoupURI *base_uri)
do_request_api_test (session, base_uri, n);
soup_test_session_abort_unref (session);
- session = soup_test_session_new (SOUP_TYPE_SESSION_SYNC,
- SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
- NULL);
+ session = soup_test_session_new (SOUP_TYPE_SESSION_SYNC, NULL);
debug_printf (1, "\nSync session, SoupMessage\n");
for (n = 0; n < n_tests; n++)
do_message_api_test (session, base_uri, n);
diff --git a/tests/requester-test.c b/tests/requester-test.c
index a4379377..660669a0 100644
--- a/tests/requester-test.c
+++ b/tests/requester-test.c
@@ -252,11 +252,17 @@ do_async_test (SoupSession *session, SoupURI *uri,
SoupMessage *msg;
RequestData data;
- requester = SOUP_REQUESTER (soup_session_get_feature (session, SOUP_TYPE_REQUESTER));
+ if (SOUP_IS_SESSION_ASYNC (session))
+ requester = SOUP_REQUESTER (soup_session_get_feature (session, SOUP_TYPE_REQUESTER));
+ else
+ requester = NULL;
data.body = g_string_new (NULL);
data.cancel = cancel;
- request = soup_requester_request_uri (requester, uri, NULL);
+ if (requester)
+ request = soup_requester_request_uri (requester, uri, NULL);
+ else
+ request = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
if (cancel) {
@@ -326,9 +332,11 @@ do_test_for_thread_and_context (SoupSession *session, const char *base_uri)
SoupRequester *requester;
SoupURI *uri;
- requester = soup_requester_new ();
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (requester));
- g_object_unref (requester);
+ if (SOUP_IS_SESSION_ASYNC (session)) {
+ requester = soup_requester_new ();
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (requester));
+ g_object_unref (requester);
+ }
soup_session_add_feature_by_type (session, SOUP_TYPE_CONTENT_SNIFFER);
debug_printf (1, " basic test\n");
@@ -572,14 +580,19 @@ do_sync_test (const char *uri_string, gboolean plain_session)
plain_session ? "SoupSession" : "SoupSessionSync");
session = soup_test_session_new (plain_session ? SOUP_TYPE_SESSION : SOUP_TYPE_SESSION_SYNC, NULL);
- requester = soup_requester_new ();
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (requester));
- g_object_unref (requester);
+ if (!plain_session) {
+ requester = soup_requester_new ();
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (requester));
+ g_object_unref (requester);
+ }
uri = soup_uri_new (uri_string);
debug_printf (1, " basic test\n");
- request = soup_requester_request_uri (requester, uri, NULL);
+ if (plain_session)
+ request = soup_session_request_uri (session, uri, NULL);
+ else
+ request = soup_requester_request_uri (requester, uri, NULL);
do_sync_request (session, request,
SOUP_STATUS_OK, response,
TRUE, FALSE);
@@ -587,7 +600,10 @@ do_sync_test (const char *uri_string, gboolean plain_session)
debug_printf (1, " chunked test\n");
soup_uri_set_path (uri, "/chunked");
- request = soup_requester_request_uri (requester, uri, NULL);
+ if (plain_session)
+ request = soup_session_request_uri (session, uri, NULL);
+ else
+ request = soup_requester_request_uri (requester, uri, NULL);
do_sync_request (session, request,
SOUP_STATUS_OK, response,
TRUE, FALSE);
@@ -595,7 +611,10 @@ do_sync_test (const char *uri_string, gboolean plain_session)
debug_printf (1, " auth test\n");
soup_uri_set_path (uri, "/auth");
- request = soup_requester_request_uri (requester, uri, NULL);
+ if (plain_session)
+ request = soup_session_request_uri (session, uri, NULL);
+ else
+ request = soup_requester_request_uri (requester, uri, NULL);
do_sync_request (session, request,
SOUP_STATUS_UNAUTHORIZED, auth_response,
TRUE, FALSE);
@@ -603,7 +622,10 @@ do_sync_test (const char *uri_string, gboolean plain_session)
debug_printf (1, " non-persistent test\n");
soup_uri_set_path (uri, "/non-persistent");
- request = soup_requester_request_uri (requester, uri, NULL);
+ if (plain_session)
+ request = soup_session_request_uri (session, uri, NULL);
+ else
+ request = soup_requester_request_uri (requester, uri, NULL);
do_sync_request (session, request,
SOUP_STATUS_OK, response,
FALSE, FALSE);
@@ -611,7 +633,10 @@ do_sync_test (const char *uri_string, gboolean plain_session)
debug_printf (1, " cancel test\n");
soup_uri_set_path (uri, "/");
- request = soup_requester_request_uri (requester, uri, NULL);
+ if (plain_session)
+ request = soup_session_request_uri (session, uri, NULL);
+ else
+ request = soup_requester_request_uri (requester, uri, NULL);
do_sync_request (session, request,
SOUP_STATUS_FORBIDDEN, NULL,
TRUE, TRUE);
diff --git a/tests/timeout-test.c b/tests/timeout-test.c
index 9d9b2d13..e523f2db 100644
--- a/tests/timeout-test.c
+++ b/tests/timeout-test.c
@@ -112,7 +112,7 @@ do_msg_tests_for_session (SoupSession *timeout_session,
}
static void
-do_request_to_session (SoupRequester *requester, const char *uri,
+do_request_to_session (SoupSession *session, const char *uri,
const char *comment, gboolean expect_timeout)
{
SoupRequest *req;
@@ -122,7 +122,7 @@ do_request_to_session (SoupRequester *requester, const char *uri,
gboolean finished = FALSE;
debug_printf (1, " req %s\n", comment);
- req = soup_requester_request (requester, uri, NULL);
+ req = soup_session_request (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
g_signal_connect (msg, "finished",
@@ -179,46 +179,30 @@ do_req_tests_for_session (SoupSession *timeout_session,
SoupSession *plain_session,
char *fast_uri, char *slow_uri)
{
- SoupRequester *timeout_requester, *idle_requester, *plain_requester;
SoupSocket *ret, *idle_first, *idle_second;
SoupSocket *plain_first, *plain_second;
debug_printf (1, "\n");
if (idle_session) {
- idle_requester = soup_requester_new ();
- soup_session_add_feature (idle_session,
- SOUP_SESSION_FEATURE (idle_requester));
- g_object_unref (idle_requester);
-
g_signal_connect (idle_session, "request-started",
G_CALLBACK (request_started_cb), &ret);
- do_request_to_session (idle_requester, fast_uri, "fast to idle", FALSE);
+ do_request_to_session (idle_session, fast_uri, "fast to idle", FALSE);
idle_first = ret;
}
if (plain_session) {
- plain_requester = soup_requester_new ();
- soup_session_add_feature (plain_session,
- SOUP_SESSION_FEATURE (plain_requester));
- g_object_unref (plain_requester);
-
g_signal_connect (plain_session, "request-started",
G_CALLBACK (request_started_cb), &ret);
- do_request_to_session (plain_requester, fast_uri, "fast to plain", FALSE);
+ do_request_to_session (plain_session, fast_uri, "fast to plain", FALSE);
plain_first = ret;
}
- timeout_requester = soup_requester_new ();
- soup_session_add_feature (timeout_session,
- SOUP_SESSION_FEATURE (timeout_requester));
- g_object_unref (timeout_requester);
-
- do_request_to_session (timeout_requester, fast_uri, "fast to timeout", FALSE);
- do_request_to_session (timeout_requester, slow_uri, "slow to timeout", TRUE);
+ do_request_to_session (timeout_session, fast_uri, "fast to timeout", FALSE);
+ do_request_to_session (timeout_session, slow_uri, "slow to timeout", TRUE);
if (idle_session) {
- do_request_to_session (idle_requester, fast_uri, "fast to idle", FALSE);
+ do_request_to_session (idle_session, fast_uri, "fast to idle", FALSE);
idle_second = ret;
g_signal_handlers_disconnect_by_func (idle_session,
(gpointer)request_started_cb,
@@ -231,7 +215,7 @@ do_req_tests_for_session (SoupSession *timeout_session,
}
if (plain_session) {
- do_request_to_session (plain_requester, fast_uri, "fast to plain", FALSE);
+ do_request_to_session (plain_session, fast_uri, "fast to plain", FALSE);
plain_second = ret;
g_signal_handlers_disconnect_by_func (plain_session,
(gpointer)request_started_cb,