summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-12-28 10:41:20 -0500
committerDan Winship <danw@gnome.org>2012-12-28 11:26:46 -0500
commit2357f3501718967003914da4f1f7659b6593aa0d (patch)
tree28b53fc12a6cfec15f65b586ab7935819ca5958a /tests
parentddfbe30e04c8a9a8981d43b21c27b8bd8336e85b (diff)
downloadlibsoup-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.
Diffstat (limited to 'tests')
-rw-r--r--tests/cache-test.c5
-rw-r--r--tests/coding-test.c33
-rw-r--r--tests/connection-test.c9
-rw-r--r--tests/proxy-test.c9
-rw-r--r--tests/requester-test.c30
-rw-r--r--tests/sniffing-test.c4
6 files changed, 59 insertions, 31 deletions
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);