diff options
author | Dan Winship <danw@gnome.org> | 2012-07-15 18:21:37 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-12-10 17:14:57 +0100 |
commit | d7117329400e47d2187ed033099d921d555f8d71 (patch) | |
tree | c3a44ec7666789968366d418211cb6d4bcac54f0 /tests | |
parent | fea7925589f6b768252b07c9df8f44ee70bca032 (diff) | |
download | libsoup-d7117329400e47d2187ed033099d921d555f8d71.tar.gz libsoup-d7117329400e47d2187ed033099d921d555f8d71.tar.bz2 libsoup-d7117329400e47d2187ed033099d921d555f8d71.zip |
SoupRequestHTTP: mirror SoupMessage fields/API
Mirror various SoupMessage-related API onto SoupRequestHTTP so that
you don't need to resort to soup_request_http_get_message().
Diffstat (limited to 'tests')
-rw-r--r-- | tests/connection-test.c | 9 | ||||
-rw-r--r-- | tests/proxy-test.c | 9 | ||||
-rw-r--r-- | tests/requester-test.c | 30 |
3 files changed, 21 insertions, 27 deletions
diff --git a/tests/connection-test.c b/tests/connection-test.c index 6b57f24d..938c7deb 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; - SoupMessage *msg; + SoupRequestHTTP *http; 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); } - msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req)); - if (msg->status_code != SOUP_STATUS_OK) { + http = SOUP_REQUEST_HTTP (req); + if (http->status_code != SOUP_STATUS_OK) { debug_printf (1, " Unexpected response: %d %s\n", - msg->status_code, msg->reason_phrase); + http->status_code, http->reason_phrase); errors++; } if (sockets[1] != sockets[0]) { @@ -379,7 +379,6 @@ 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 048acfa7..3466c569 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,7 +162,6 @@ 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) { @@ -183,13 +182,13 @@ test_url_new_api (const char *url, int proxy, guint expected, g_object_unref (stream); } - debug_printf (1, " %d %s\n", msg->status_code, msg->reason_phrase); - if (msg->status_code != expected) { + 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, " 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 660669a0..4a276783 100644 --- a/tests/requester-test.c +++ b/tests/requester-test.c @@ -142,10 +142,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); @@ -157,15 +157,14 @@ auth_test_sent (GObject *source, GAsyncResult *res, gpointer user_data) return; } - 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); + + if (http->status_code != SOUP_STATUS_UNAUTHORIZED) { + debug_printf (1, " GET failed: %d %s\n", http->status_code, + http->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) { @@ -263,11 +262,12 @@ 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", @@ -275,7 +275,6 @@ 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); @@ -283,16 +282,16 @@ do_async_test (SoupSession *session, SoupURI *uri, g_signal_handler_disconnect (session, started_id); - if (msg->status_code != expected_status) { + if (SOUP_REQUEST_HTTP (request)->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 (msg); + g_object_unref (request); if (!expected_response) { if (data.body->len) { @@ -468,10 +467,11 @@ 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", @@ -491,29 +491,25 @@ 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 (msg->status_code != expected_status) { + if (SOUP_REQUEST_HTTP (request)->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 { |