diff options
author | Dan Winship <danw@gnome.org> | 2012-12-28 10:41:20 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-12-28 11:26:46 -0500 |
commit | 2357f3501718967003914da4f1f7659b6593aa0d (patch) | |
tree | 28b53fc12a6cfec15f65b586ab7935819ca5958a | |
parent | ddfbe30e04c8a9a8981d43b21c27b8bd8336e85b (diff) | |
download | libsoup-2357f3501718967003914da4f1f7659b6593aa0d.tar.gz libsoup-2357f3501718967003914da4f1f7659b6593aa0d.tar.bz2 libsoup-2357f3501718967003914da4f1f7659b6593aa0d.zip |
Revert the mirroring of SoupMessage API onto SoupRequestHTTP.
SoupMessage isn't being deprecated, and mirroring its API onto
SoupRequestHTTP is just going to result in always having to add every
new API twice. Also, it turns out to be less useful than originally
expected anyway, since you end up having to cast between SoupRequest
and SoupRequestHTTP frequently anyway.
This reverts commit d7117329400e47d2187ed033099d921d555f8d71 and most of
commit 53c270d0e2868fa5ad48ce864f10a9486b11a071.
-rw-r--r-- | docs/reference/libsoup-2.4-sections.txt | 10 | ||||
-rw-r--r-- | libsoup/libsoup-2.4.sym | 8 | ||||
-rw-r--r-- | libsoup/soup-request-http.c | 506 | ||||
-rw-r--r-- | libsoup/soup-request-http.h | 41 | ||||
-rw-r--r-- | libsoup/soup-request.c | 30 | ||||
-rw-r--r-- | libsoup/soup-request.h | 4 | ||||
-rw-r--r-- | tests/cache-test.c | 5 | ||||
-rw-r--r-- | tests/coding-test.c | 33 | ||||
-rw-r--r-- | tests/connection-test.c | 9 | ||||
-rw-r--r-- | tests/proxy-test.c | 9 | ||||
-rw-r--r-- | tests/requester-test.c | 30 | ||||
-rw-r--r-- | tests/sniffing-test.c | 4 |
12 files changed, 61 insertions, 628 deletions
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt index db45167f..f3595973 100644 --- a/docs/reference/libsoup-2.4-sections.txt +++ b/docs/reference/libsoup-2.4-sections.txt @@ -1100,8 +1100,6 @@ soup_request_get_content_type soup_request_get_session soup_request_get_uri <SUBSECTION> -soup_request_disable_feature -<SUBSECTION> SOUP_REQUEST_SESSION SOUP_REQUEST_URI <SUBSECTION Standard> @@ -1153,14 +1151,6 @@ soup_request_file_get_type <FILE>soup-request-http</FILE> <TITLE>SoupRequestHTTP</TITLE> SoupRequestHTTP -soup_request_http_set_method -soup_request_http_set_request_version -soup_request_http_set_flags -soup_request_http_get_flags -soup_request_http_set_first_party -soup_request_http_get_first_party -soup_request_http_get_https_status -<SUBSECTION> soup_request_http_get_message <SUBSECTION Standard> SOUP_IS_REQUEST_HTTP diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym index 66e5bf7f..7080ac5b 100644 --- a/libsoup/libsoup-2.4.sym +++ b/libsoup/libsoup-2.4.sym @@ -319,7 +319,6 @@ soup_requester_get_type soup_requester_new soup_requester_request soup_requester_request_uri -soup_request_disable_feature soup_request_error_get_type soup_request_error_quark soup_request_file_get_file @@ -329,15 +328,8 @@ soup_request_get_content_type soup_request_get_session soup_request_get_type soup_request_get_uri -soup_request_http_get_first_party -soup_request_http_get_flags -soup_request_http_get_https_status soup_request_http_get_message soup_request_http_get_type -soup_request_http_set_first_party -soup_request_http_set_flags -soup_request_http_set_method -soup_request_http_set_request_version soup_request_send soup_request_send_async soup_request_send_finish diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c index e932217a..4e527ccd 100644 --- a/libsoup/soup-request-http.c +++ b/libsoup/soup-request-http.c @@ -46,49 +46,9 @@ G_DEFINE_TYPE (SoupRequestHTTP, soup_request_http, SOUP_TYPE_REQUEST) -/** - * SoupRequestHTTP: - * @method: the HTTP method - * @request_uri: the request URI - * @request_version: the HTTP version of the request - * @request_headers: the request headers - * @status_code: the HTTP status code - * @reason_phrase: the status phrase associated with @status_code - * @response_version: the HTTP version of the response - * @response_headers: the response headers - * - * Represents an HTTP message being sent or received via the - * #SoupRequest API. The fields on this object reflect the values on - * the request's underlying #SoupMessage; see the #SoupMessage - * documentation for more information. - * - * Since: 2.42 - */ - -enum { - PROP_0, - - PROP_METHOD, - PROP_REQUEST_URI, - PROP_REQUEST_VERSION, - PROP_REQUEST_HEADERS, - PROP_STATUS_CODE, - PROP_REASON_PHRASE, - PROP_RESPONSE_VERSION, - PROP_RESPONSE_HEADERS, - - PROP_FLAGS, - PROP_FIRST_PARTY, - PROP_TLS_CERTIFICATE, - PROP_TLS_ERRORS, - - LAST_PROP -}; - struct _SoupRequestHTTPPrivate { SoupMessage *msg; char *content_type; - gboolean sent; }; static void content_sniffed (SoupMessage *msg, @@ -102,125 +62,6 @@ soup_request_http_init (SoupRequestHTTP *http) http->priv = G_TYPE_INSTANCE_GET_PRIVATE (http, SOUP_TYPE_REQUEST_HTTP, SoupRequestHTTPPrivate); } -static void -soup_request_http_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupRequestHTTP *http = SOUP_REQUEST_HTTP (object); - - switch (prop_id) { - case PROP_METHOD: - soup_request_http_set_method (http, g_value_get_string (value)); - break; - case PROP_REQUEST_VERSION: - soup_request_http_set_request_version (http, g_value_get_enum (value)); - break; - case PROP_FLAGS: - soup_request_http_set_flags (http, g_value_get_flags (value)); - break; - case PROP_FIRST_PARTY: - soup_request_http_set_first_party (http, g_value_get_boxed (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -soup_request_http_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupRequestHTTP *http = SOUP_REQUEST_HTTP (object); - GTlsCertificate *cert; - GTlsCertificateFlags errors; - - switch (prop_id) { - case PROP_METHOD: - g_value_set_string (value, http->method); - break; - case PROP_REQUEST_URI: - g_value_set_boxed (value, http->request_uri); - break; - case PROP_REQUEST_VERSION: - g_value_set_enum (value, http->request_version); - break; - case PROP_REQUEST_HEADERS: - g_value_set_boxed (value, http->request_headers); - break; - case PROP_STATUS_CODE: - g_value_set_uint (value, http->status_code); - break; - case PROP_REASON_PHRASE: - g_value_set_string (value, http->reason_phrase); - break; - case PROP_RESPONSE_VERSION: - g_value_set_enum (value, http->response_version); - break; - case PROP_RESPONSE_HEADERS: - g_value_set_boxed (value, http->request_headers); - break; - case PROP_FLAGS: - g_value_set_flags (value, soup_message_get_flags (http->priv->msg)); - break; - case PROP_FIRST_PARTY: - g_value_set_boxed (value, soup_message_get_first_party (http->priv->msg)); - break; - case PROP_TLS_CERTIFICATE: - g_object_get (G_OBJECT (http->priv->msg), - "tls-certificate", &cert, - NULL); - g_value_set_object (value, cert); - break; - case PROP_TLS_ERRORS: - g_object_get (G_OBJECT (http->priv->msg), - "tls-errors", &errors, - NULL); - g_value_set_flags (value, errors); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -message_property_changed (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - SoupRequestHTTP *http = user_data; - - if (!strcmp (pspec->name, "method")) { - http->method = http->priv->msg->method; - g_object_notify (G_OBJECT (http), "method"); - } else if (!strcmp (pspec->name, "uri")) { - http->request_uri = soup_message_get_uri (http->priv->msg); - g_object_notify (G_OBJECT (http), "request-uri"); - } else if (!strcmp (pspec->name, "status-code")) { - http->status_code = http->priv->msg->status_code; - g_object_notify (G_OBJECT (http), "status-code"); - } else if (!strcmp (pspec->name, "reason-phrase")) { - http->reason_phrase = http->priv->msg->reason_phrase; - g_object_notify (G_OBJECT (http), "reason-phrase"); - } else if (!strcmp (pspec->name, "http-version")) { - if (!http->priv->sent) { - http->request_version = soup_message_get_http_version (http->priv->msg); - g_object_notify (G_OBJECT (http), "request-version"); - } else { - http->response_version = soup_message_get_http_version (http->priv->msg); - g_object_notify (G_OBJECT (http), "response-version"); - } - } else if (!strcmp (pspec->name, "flags")) - g_object_notify (G_OBJECT (http), "flags"); - else if (!strcmp (pspec->name, "first-party")) - g_object_notify (G_OBJECT (http), "first-party"); - else if (!strcmp (pspec->name, "tls-certificate")) - g_object_notify (G_OBJECT (http), "tls-certificate"); - else if (!strcmp (pspec->name, "tls-errors")) - g_object_notify (G_OBJECT (http), "tls-errors"); -} - static gboolean soup_request_http_check_uri (SoupRequest *request, SoupURI *uri, @@ -236,17 +77,6 @@ soup_request_http_check_uri (SoupRequest *request, g_signal_connect (http->priv->msg, "content-sniffed", G_CALLBACK (content_sniffed), http); - - g_signal_connect (http->priv->msg, "notify", - G_CALLBACK (message_property_changed), http); - - http->method = http->priv->msg->method; - http->request_uri = soup_message_get_uri (http->priv->msg); - http->request_version = SOUP_HTTP_1_1; - http->request_headers = http->priv->msg->request_headers; - http->response_version = SOUP_HTTP_1_1; - http->response_headers = http->priv->msg->response_headers; - return TRUE; } @@ -259,9 +89,6 @@ soup_request_http_finalize (GObject *object) g_signal_handlers_disconnect_by_func (http->priv->msg, G_CALLBACK (content_sniffed), http); - g_signal_handlers_disconnect_by_func (http->priv->msg, - G_CALLBACK (message_property_changed), - http); g_object_unref (http->priv->msg); } @@ -280,7 +107,6 @@ soup_request_http_send (SoupRequest *request, g_return_val_if_fail (!SOUP_IS_SESSION_ASYNC (session), NULL); - http->priv->sent = TRUE; return soup_session_send_request (session, http->priv->msg, cancellable, error); } @@ -313,8 +139,6 @@ soup_request_http_send_async (SoupRequest *request, g_return_if_fail (!SOUP_IS_SESSION_SYNC (session)); - http->priv->sent = TRUE; - task = g_task_new (request, cancellable, callback, user_data); soup_session_send_request_async (session, http->priv->msg, cancellable, http_input_stream_ready_cb, task); @@ -383,8 +207,6 @@ soup_request_http_class_init (SoupRequestHTTPClass *request_http_class) request_class->schemes = http_schemes; - object_class->set_property = soup_request_http_set_property; - object_class->get_property = soup_request_http_get_property; object_class->finalize = soup_request_http_finalize; request_class->check_uri = soup_request_http_check_uri; @@ -393,199 +215,6 @@ soup_request_http_class_init (SoupRequestHTTPClass *request_http_class) request_class->send_finish = soup_request_http_send_finish; request_class->get_content_length = soup_request_http_get_content_length; request_class->get_content_type = soup_request_http_get_content_type; - - /** - * SoupRequestHTTP:method: - * - * The request's HTTP method; "GET" by default. Note that in - * C you can simply read the <literal>method</literal> field - * of the #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_METHOD, - g_param_spec_string ("method", - "Method", - "The HTTP method", - SOUP_METHOD_GET, - G_PARAM_READWRITE)); - /** - * SoupRequestHTTP:request-uri: - * - * The request's #SoupURI. Note that in C you can simply read - * the <literal>request_uri</literal> field of the - * #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_REQUEST_URI, - g_param_spec_boxed ("request-uri", - "URI", - "The Request-URI", - SOUP_TYPE_URI, - G_PARAM_READWRITE)); - /** - * SoupRequestHTTP:request-version: - * - * The #SoupHTTPVersion used when sending the request; - * %SOUP_HTTP_1_1 by default. Note that in C you can simply - * read the <literal>request_version</literal> field of the - * #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_REQUEST_VERSION, - g_param_spec_enum ("request-version", - "Request HTTP Version", - "The SoupHTTPVersion used when sending the request", - SOUP_TYPE_HTTP_VERSION, - SOUP_HTTP_1_1, - G_PARAM_READWRITE)); - /** - * SoupRequestHTTP:request-headers: - * - * The request's HTTP request headers. Note that in C you can - * simply read the <literal>request_headers</literal> field of - * the #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_REQUEST_HEADERS, - g_param_spec_boxed ("request-headers", - "Request Headers", - "The HTTP request headers", - SOUP_TYPE_MESSAGE_HEADERS, - G_PARAM_READABLE)); - - /** - * SoupRequestHTTP:status-code: - * - * The request's HTTP response status code. Note that in C you - * can simply read the <literal>status_code</literal> field of - * the #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_STATUS_CODE, - g_param_spec_uint ("status-code", - "Status code", - "The HTTP response status code", - 0, 599, 0, - G_PARAM_READABLE)); - /** - * SoupRequestHTTP:reason-phrase: - * - * The request's HTTP response reason phrase. Note that in C - * you can simply read the <literal>reason_phrase</literal> - * field of the #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_REASON_PHRASE, - g_param_spec_string ("reason-phrase", - "Reason phrase", - "The HTTP response reason phrase", - NULL, - G_PARAM_READABLE)); - /** - * SoupRequestHTTP:response-version: - * - * The #SoupHTTPVersion that the server replied with. Note - * that in C you can simply read the - * <literal>response_version</literal> field of the - * #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_RESPONSE_VERSION, - g_param_spec_enum ("response-version", - "Response HTTP Version", - "The SoupHTTPVersion that the server replied with", - SOUP_TYPE_HTTP_VERSION, - SOUP_HTTP_1_1, - G_PARAM_READABLE)); - /** - * SoupRequestHTTP:response-headers: - * - * The request's HTTP response headers. Note that in C you can - * simply read the <literal>response_headers</literal> field - * of the #SoupRequestHTTP. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_RESPONSE_HEADERS, - g_param_spec_boxed ("response-headers", - "Response Headers", - "The HTTP response headers", - SOUP_TYPE_MESSAGE_HEADERS, - G_PARAM_READABLE)); - - /** - * SoupRequestHTTP:flags: - * - * The request's #SoupMessageFlags. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_FLAGS, - g_param_spec_flags ("flags", - "Flags", - "Various request options", - SOUP_TYPE_MESSAGE_FLAGS, - 0, - G_PARAM_READWRITE)); - /** - * SoupRequestHTTP:first-party: - * - * The #SoupURI loaded in the application when the request was - * queued. - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_FIRST_PARTY, - g_param_spec_boxed ("first-party", - "First party", - "The URI loaded in the application when the request was queued.", - SOUP_TYPE_URI, - G_PARAM_READWRITE)); - /** - * SoupRequestHTTP:tls-certificate: - * - * The #GTlsCertificate associated with the request - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_TLS_CERTIFICATE, - g_param_spec_object ("tls-certificate", - "TLS Certificate", - "The TLS certificate associated with the request", - G_TYPE_TLS_CERTIFICATE, - G_PARAM_READABLE)); - /** - * SoupRequestHTTP:tls-errors: - * - * The verification errors on #SoupRequestHTTP:tls-certificate - * - * Since: 2.42 - */ - g_object_class_install_property ( - object_class, PROP_TLS_ERRORS, - g_param_spec_flags ("tls-errors", - "TLS Errors", - "The verification errors on the request's TLS certificate", - G_TYPE_TLS_CERTIFICATE_FLAGS, 0, - G_PARAM_READABLE)); } /** @@ -596,7 +225,7 @@ soup_request_http_class_init (SoupRequestHTTPClass *request_http_class) * * Returns: (transfer full): a new reference to the #SoupMessage * - * Since: 2.42 + * Since: 2.40 */ SoupMessage * soup_request_http_get_message (SoupRequestHTTP *http) @@ -605,136 +234,3 @@ soup_request_http_get_message (SoupRequestHTTP *http) return g_object_ref (http->priv->msg); } - -/** - * soup_request_http_set_method: - * @http: a #SoupRequestHTTP - * @method: the HTTP method - * - * Sets @http to use @method as its request method. - * - * Since: 2.42 - */ -void -soup_request_http_set_method (SoupRequestHTTP *http, - const char *method) -{ - g_object_set (G_OBJECT (http->priv->msg), - "method", method, - NULL); -} - -/** - * soup_request_http_set_request_version: - * @http: a #SoupRequestHTTP - * @version: the version of HTTP to use - * - * Sets @http to use the version of HTTP specified by @version in its - * request. - * - * Since: 2.42 - */ -void -soup_request_http_set_request_version (SoupRequestHTTP *http, - SoupHTTPVersion version) -{ - g_return_if_fail (!http->priv->sent); - - g_object_set (G_OBJECT (http->priv->msg), - "http-version", version, - NULL); -} - -/** - * soup_request_http_get_first_party: - * @http: a #SoupRequestHTTP - * - * Gets @http's first-party #SoupURI; see the documentation - * for #SoupCookieJarAcceptPolicy for more details. - * - * Returns: (transfer none): @http's first-party URI - * - * Since: 2.42 - */ -SoupURI * -soup_request_http_get_first_party (SoupRequestHTTP *http) -{ - return soup_message_get_first_party (http->priv->msg); -} - -/** - * soup_request_http_set_first_party: - * @http: a #SoupRequestHTTP - * @first_party: the #SoupURI for the request's first party - * - * Sets @first_party as the main document #SoupURI for @http. For - * details of when and how this is used refer to the documentation for - * #SoupCookieJarAcceptPolicy. - * - * Since: 2.42 - */ -void -soup_request_http_set_first_party (SoupRequestHTTP *http, - SoupURI *first_party) -{ - soup_message_set_first_party (http->priv->msg, - first_party); -} - -/** - * soup_request_http_get_flags: - * @http: a #SoupRequestHTTP - * - * Gets @http's message flags. - * - * Returns: @http's message flags - * - * Since: 2.42 - */ -SoupMessageFlags -soup_request_http_get_flags (SoupRequestHTTP *http) -{ - return soup_message_get_flags (http->priv->msg); -} - -/** - * soup_request_http_set_flags: - * @http: a #SoupRequestHTTP - * @flags: a set of #SoupMessageFlags values - * - * Sets the specified flags on @msg. Note that some #SoupMessageFlags - * (such as %SOUP_MESSAGE_CAN_REBUILD and - * %SOUP_MESSAGE_OVERWRITE_CHUNKS) have no effect in the #SoupRequest - * API. - * - * Since: 2.42 - */ -void -soup_request_http_set_flags (SoupRequestHTTP *http, - SoupMessageFlags flags) -{ - soup_message_set_flags (http->priv->msg, flags); -} - -/** - * soup_request_http_get_https_status: - * @http: a #SoupRequestHTTP - * @certificate: (out) (transfer none): @http's TLS certificate - * @errors: (out): the verification status of @certificate - * - * If @http is using https, this retrieves the #GTlsCertificate - * associated with its connection, and the #GTlsCertificateFlags showing - * what problems, if any, have been found with that certificate. - * - * Return value: %TRUE if @http uses https, %FALSE if not - * - * Since: 2.42 - */ -gboolean -soup_request_http_get_https_status (SoupRequestHTTP *http, - GTlsCertificate **certificate, - GTlsCertificateFlags *errors) -{ - return soup_message_get_https_status (http->priv->msg, - certificate, errors); -} diff --git a/libsoup/soup-request-http.h b/libsoup/soup-request-http.h index 5335b10b..271a8052 100644 --- a/libsoup/soup-request-http.h +++ b/libsoup/soup-request-http.h @@ -23,8 +23,6 @@ #define SOUP_REQUEST_HTTP_H 1 #include "soup-request.h" -#include "soup-message.h" -#include "soup-message-headers.h" G_BEGIN_DECLS @@ -40,20 +38,7 @@ typedef struct _SoupRequestHTTPPrivate SoupRequestHTTPPrivate; struct _SoupRequestHTTP { SoupRequest parent; - /*< public >*/ - const char *method; - SoupURI *request_uri; - SoupHTTPVersion request_version; - SoupMessageHeaders *request_headers; - - guint status_code; - char *reason_phrase; - SoupHTTPVersion response_version; - SoupMessageHeaders *response_headers; - - /*< private >*/ SoupRequestHTTPPrivate *priv; - }; typedef struct { @@ -64,31 +49,7 @@ SOUP_AVAILABLE_IN_2_34 GType soup_request_http_get_type (void); SOUP_AVAILABLE_IN_2_34 -SoupMessage *soup_request_http_get_message (SoupRequestHTTP *http); - -SOUP_AVAILABLE_IN_2_42 -void soup_request_http_set_method (SoupRequestHTTP *http, - const char *method); -SOUP_AVAILABLE_IN_2_42 -void soup_request_http_set_request_version (SoupRequestHTTP *http, - SoupHTTPVersion version); - -SOUP_AVAILABLE_IN_2_42 -SoupURI *soup_request_http_get_first_party (SoupRequestHTTP *http); -SOUP_AVAILABLE_IN_2_42 -void soup_request_http_set_first_party (SoupRequestHTTP *http, - SoupURI *first_party); - -SOUP_AVAILABLE_IN_2_42 -SoupMessageFlags soup_request_http_get_flags (SoupRequestHTTP *http); -SOUP_AVAILABLE_IN_2_42 -void soup_request_http_set_flags (SoupRequestHTTP *http, - SoupMessageFlags flags); - -SOUP_AVAILABLE_IN_2_42 -gboolean soup_request_http_get_https_status (SoupRequestHTTP *http, - GTlsCertificate **certificate, - GTlsCertificateFlags *errors); +SoupMessage *soup_request_http_get_message (SoupRequestHTTP *http); G_END_DECLS diff --git a/libsoup/soup-request.c b/libsoup/soup-request.c index 02d0ca47..0dfe3eff 100644 --- a/libsoup/soup-request.c +++ b/libsoup/soup-request.c @@ -30,7 +30,6 @@ #include "soup-request.h" #include "soup.h" #include "soup-requester.h" -#include "soup-request-http.h" /** * SECTION:soup-request @@ -404,32 +403,3 @@ soup_request_get_content_type (SoupRequest *request) { return SOUP_REQUEST_GET_CLASS (request)->get_content_type (request); } - -/** - * soup_request_disable_feature: - * @request: a #SoupRequest - * @feature_type: the #GType of a #SoupSessionFeature - * - * This disables the actions of #SoupSessionFeature<!-- -->s with the - * given @feature_type (or a subclass of that type) on @request, so - * that @request is processed as though the feature(s) hadn't been - * added to the session. Eg, passing #SOUP_TYPE_PROXY_URI_RESOLVER for - * @feature_type will disable proxy handling and cause @request to be - * sent directly to the indicated origin server, regardless of system - * proxy configuration. - * - * Since: 2.42 - */ -void -soup_request_disable_feature (SoupRequest *request, - GType feature_type) -{ - SoupMessage *msg; - - /* For now, features only affect SoupMessages, so... */ - if (SOUP_IS_REQUEST_HTTP (request)) { - msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); - soup_message_disable_feature (msg, feature_type); - g_object_unref (msg); - } -} diff --git a/libsoup/soup-request.h b/libsoup/soup-request.h index e44a7f24..84ad6d6b 100644 --- a/libsoup/soup-request.h +++ b/libsoup/soup-request.h @@ -98,10 +98,6 @@ goffset soup_request_get_content_length (SoupRequest *request); SOUP_AVAILABLE_IN_2_34 const char *soup_request_get_content_type (SoupRequest *request); -SOUP_AVAILABLE_IN_2_42 -void soup_request_disable_feature (SoupRequest *request, - GType feature_type); - G_END_DECLS #endif /* SOUP_REQUEST_H */ diff --git a/tests/cache-test.c b/tests/cache-test.c index 8f8d2b04..ac19bfe5 100644 --- a/tests/cache-test.c +++ b/tests/cache-test.c @@ -122,6 +122,7 @@ do_request (SoupSession *session, ...) { SoupRequestHTTP *req; + SoupMessage *msg; GInputStream *stream; SoupURI *uri; va_list ap; @@ -135,13 +136,15 @@ do_request (SoupSession *session, uri = soup_uri_new_with_base (base_uri, path); req = soup_session_request_http_uri (session, method, uri, NULL); soup_uri_free (uri); + msg = soup_request_http_get_message (req); va_start (ap, path); while ((header = va_arg (ap, const char *))) { value = va_arg (ap, const char *); - soup_message_headers_append (req->request_headers, + soup_message_headers_append (msg->request_headers, header, value); } + g_object_unref (msg); stream = soup_test_request_send (SOUP_REQUEST (req), NULL, &error); if (!stream) { diff --git a/tests/coding-test.c b/tests/coding-test.c index 7723c19d..5d4f0e32 100644 --- a/tests/coding-test.c +++ b/tests/coding-test.c @@ -397,6 +397,7 @@ do_coding_req_test (void) { SoupSession *session; SoupRequestHTTP *reqh; + SoupMessage *msg; SoupURI *uri; GByteArray *plain, *cmp; @@ -425,8 +426,10 @@ do_coding_req_test (void) /* Plain text data, claim gzip w/ junk */ debug_printf (1, " GET /mbox, Accept-Encoding: gzip, plus trailing junk\n"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "trailing-junk"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "gzip", "text/plain", EXPECT_DECODED); check_req_bodies (plain, cmp, "plain", "compressed w/ junk"); g_byte_array_free (cmp, TRUE); @@ -435,8 +438,10 @@ 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"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "force-encode"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "gzip", "text/plain", EXPECT_NOT_DECODED); /* Failed content-decoding should have left the body untouched @@ -450,8 +455,10 @@ do_coding_req_test (void) /* Plain text data, claim deflate */ debug_printf (1, " GET /mbox, Accept-Encoding: deflate\n"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "prefer-deflate-zlib"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "deflate", "text/plain", EXPECT_DECODED); check_req_bodies (plain, cmp, "plain", "compressed"); g_byte_array_free (cmp, TRUE); @@ -460,8 +467,10 @@ do_coding_req_test (void) /* Plain text data, claim deflate w/ junk */ debug_printf (1, " GET /mbox, Accept-Encoding: deflate, plus trailing junk\n"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "prefer-deflate-zlib, trailing-junk"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "deflate", "text/plain", EXPECT_DECODED); check_req_bodies (plain, cmp, "plain", "compressed w/ junk"); g_byte_array_free (cmp, TRUE); @@ -470,8 +479,10 @@ 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"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "force-encode, prefer-deflate-zlib"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "deflate", "text/plain", EXPECT_NOT_DECODED); check_req_bodies (plain, cmp, "plain", "mis-encoded"); g_byte_array_free (cmp, TRUE); @@ -480,8 +491,10 @@ do_coding_req_test (void) /* Plain text data, claim deflate (no zlib headers)*/ debug_printf (1, " GET /mbox, Accept-Encoding: deflate (raw data)\n"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "prefer-deflate-raw"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "deflate", "text/plain", EXPECT_DECODED); check_req_bodies (plain, cmp, "plain", "compressed"); g_byte_array_free (cmp, TRUE); @@ -490,8 +503,10 @@ 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"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "force-encode, prefer-deflate-raw"); + g_object_unref (msg); cmp = do_single_coding_req_test (reqh, "deflate", "text/plain", EXPECT_NOT_DECODED); check_req_bodies (plain, cmp, "plain", "mis-encoded"); g_byte_array_free (cmp, TRUE); @@ -530,8 +545,10 @@ do_coding_empty_test (void) debug_printf (1, " SoupRequest\n"); reqh = soup_session_request_http_uri (session, "GET", uri, NULL); - soup_message_headers_append (reqh->request_headers, + msg = soup_request_http_get_message (reqh); + soup_message_headers_append (msg->request_headers, "X-Test-Options", "empty"); + g_object_unref (msg); body = do_single_coding_req_test (reqh, "gzip", "text/plain", EXPECT_NOT_DECODED); g_byte_array_free (body, TRUE); g_object_unref (reqh); diff --git a/tests/connection-test.c b/tests/connection-test.c index 938c7deb..6b57f24d 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -300,7 +300,7 @@ static void do_timeout_req_test_for_session (SoupSession *session) { SoupRequest *req; - SoupRequestHTTP *http; + SoupMessage *msg; GInputStream *stream; SoupSocket *sockets[4] = { NULL, NULL, NULL, NULL }; SoupURI *timeout_uri; @@ -360,10 +360,10 @@ do_timeout_req_test_for_session (SoupSession *session) g_object_unref (stream); } - http = SOUP_REQUEST_HTTP (req); - if (http->status_code != SOUP_STATUS_OK) { + msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req)); + if (msg->status_code != SOUP_STATUS_OK) { debug_printf (1, " Unexpected response: %d %s\n", - http->status_code, http->reason_phrase); + msg->status_code, msg->reason_phrase); errors++; } if (sockets[1] != sockets[0]) { @@ -379,6 +379,7 @@ do_timeout_req_test_for_session (SoupSession *session) debug_printf (1, " Message was retried again??\n"); errors++; } + g_object_unref (msg); g_object_unref (req); for (i = 0; sockets[i]; i++) diff --git a/tests/proxy-test.c b/tests/proxy-test.c index 3466c569..048acfa7 100644 --- a/tests/proxy-test.c +++ b/tests/proxy-test.c @@ -131,8 +131,8 @@ test_url_new_api (const char *url, int proxy, guint expected, { SoupSession *session; SoupURI *proxy_uri; + SoupMessage *msg; SoupRequest *request; - SoupRequestHTTP *http; GInputStream *stream; GError *error = NULL; @@ -162,6 +162,7 @@ test_url_new_api (const char *url, int proxy, guint expected, } 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); if (!stream) { @@ -182,13 +183,13 @@ test_url_new_api (const char *url, int proxy, guint expected, g_object_unref (stream); } - http = SOUP_REQUEST_HTTP (request); - debug_printf (1, " %d %s\n", http->status_code, http->reason_phrase); - if (http->status_code != expected) { + debug_printf (1, " %d %s\n", msg->status_code, msg->reason_phrase); + if (msg->status_code != expected) { debug_printf (1, " EXPECTED %d!\n", expected); errors++; } + g_object_unref (msg); g_object_unref (request); soup_test_session_abort_unref (session); diff --git a/tests/requester-test.c b/tests/requester-test.c index 0a61815b..a4bb5b62 100644 --- a/tests/requester-test.c +++ b/tests/requester-test.c @@ -145,10 +145,10 @@ test_read_ready (GObject *source, GAsyncResult *res, gpointer user_data) static void auth_test_sent (GObject *source, GAsyncResult *res, gpointer user_data) { - SoupRequestHTTP *http = SOUP_REQUEST_HTTP (source); RequestData *data = user_data; GInputStream *stream; GError *error = NULL; + SoupMessage *msg; const char *content_type; stream = soup_request_send_finish (SOUP_REQUEST (source), res, &error); @@ -160,14 +160,15 @@ auth_test_sent (GObject *source, GAsyncResult *res, gpointer user_data) return; } - - if (http->status_code != SOUP_STATUS_UNAUTHORIZED) { - debug_printf (1, " GET failed: %d %s\n", http->status_code, - http->reason_phrase); + msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (source)); + if (msg->status_code != SOUP_STATUS_UNAUTHORIZED) { + debug_printf (1, " GET failed: %d %s\n", msg->status_code, + msg->reason_phrase); errors++; g_main_loop_quit (loop); return; } + g_object_unref (msg); content_type = soup_request_get_content_type (SOUP_REQUEST (source)); if (g_strcmp0 (content_type, "text/html") != 0) { @@ -265,12 +266,11 @@ do_async_test (SoupSession *session, SoupURI *uri, 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) { - msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); g_signal_connect (msg, "got-headers", G_CALLBACK (cancel_message), session); - g_object_unref (msg); } started_id = g_signal_connect (session, "request-started", @@ -278,6 +278,7 @@ do_async_test (SoupSession *session, SoupURI *uri, &socket); soup_request_send_async (request, NULL, callback, &data); + g_object_unref (request); loop = g_main_loop_new (soup_session_get_async_context (session), TRUE); g_main_loop_run (loop); @@ -285,16 +286,16 @@ do_async_test (SoupSession *session, SoupURI *uri, g_signal_handler_disconnect (session, started_id); - if (SOUP_REQUEST_HTTP (request)->status_code != expected_status) { + if (msg->status_code != expected_status) { debug_printf (1, " GET failed: %d %s (expected %d)\n", msg->status_code, msg->reason_phrase, expected_status); + g_object_unref (msg); g_object_unref (socket); - g_object_unref (request); errors++; return; } - g_object_unref (request); + g_object_unref (msg); if (!expected_response) { if (data.body->len) { @@ -470,11 +471,10 @@ do_sync_request (SoupSession *session, SoupRequest *request, guint started_id; SoupSocket *socket = NULL; + msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); if (cancel) { - msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); g_signal_connect (msg, "got-headers", G_CALLBACK (cancel_message), session); - g_object_unref (msg); } started_id = g_signal_connect (session, "request-started", @@ -494,25 +494,29 @@ do_sync_request (SoupSession *session, SoupRequest *request, errors++; } g_clear_error (&error); + g_object_unref (msg); g_object_unref (socket); return; } else if (!in) { debug_printf (1, " soup_request_send failed: %s\n", error->message); + g_object_unref (msg); g_clear_error (&error); g_object_unref (socket); errors++; return; } - if (SOUP_REQUEST_HTTP (request)->status_code != expected_status) { + if (msg->status_code != expected_status) { debug_printf (1, " GET failed: %d %s\n", msg->status_code, msg->reason_phrase); + g_object_unref (msg); g_object_unref (in); g_object_unref (socket); errors++; return; } + g_object_unref (msg); body = g_string_new (NULL); do { diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c index ab8099da..f28ddaf8 100644 --- a/tests/sniffing-test.c +++ b/tests/sniffing-test.c @@ -436,7 +436,9 @@ test_disabled (const char *path) g_object_unref (msg); req = soup_session_request_uri (session, uri, NULL); - soup_request_disable_feature (req, SOUP_TYPE_CONTENT_SNIFFER); + msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req)); + soup_message_disable_feature (msg, SOUP_TYPE_CONTENT_SNIFFER); + g_object_unref (msg); stream = soup_test_request_send (req, NULL, &error); if (stream) { soup_test_request_close_stream (req, stream, NULL, &error); |