[librest/wip/baedert/tests] proxy-call: Set the payload



commit 695a8df1b0ead32a57fd6357fe5311123526f1cf
Author: Timm Bäder <mail baedert org>
Date:   Tue Feb 21 11:37:22 2017 +0100

    proxy-call: Set the payload
    
    Before this, it was impossible to get the server payload from a proxy
    call invoked via rest_proxy_call_invoke.
    Also test that this works.

 rest/rest-proxy-call.c   |    2 +-
 tests/proxy-continuous.c |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index a621ba4..913112a 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -1083,7 +1083,7 @@ _upload_call_message_completed_cb (SoupSession *session,
   priv->status_code = message->status_code;
   priv->status_message = g_strdup (message->reason_phrase);
 
-  _handle_error_from_message (message, &error);
+  finish_call (call, message, &error);
 
   if (error != NULL)
     g_task_return_error (task, error);
diff --git a/tests/proxy-continuous.c b/tests/proxy-continuous.c
index 77c5626..87bd1f8 100644
--- a/tests/proxy-continuous.c
+++ b/tests/proxy-continuous.c
@@ -31,6 +31,8 @@
 
 #define NUM_CHUNKS 20
 #define SIZE_CHUNK 4
+#define UPLOAD_SUCCESSFUL "Upload successful"
+
 static guint8 server_count = 0;
 static guint8 client_count = 0;
 
@@ -95,6 +97,8 @@ server_callback (SoupServer *server, SoupMessage *msg,
   else if (strcmp (path, "/upload") == 0)
     {
       soup_message_set_status (msg, SOUP_STATUS_OK);
+      soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
+                                 UPLOAD_SUCCESSFUL, strlen (UPLOAD_SUCCESSFUL));
     }
   else
     {
@@ -177,6 +181,8 @@ upload_callback (RestProxyCall *call,
                  gpointer       user_data)
 {
   g_assert (REST_IS_PROXY_CALL (call));
+  g_assert (total < uploaded);
+  g_assert_no_error (error);
 }
 
 static void
@@ -191,6 +197,9 @@ upload_done_cb (GObject      *source_object,
   rest_proxy_call_upload_finish (call, result, &error);
   g_assert_no_error (error);
 
+  g_assert_nonnull (rest_proxy_call_get_payload (call));
+  g_assert_cmpint (rest_proxy_call_get_payload_length (call), ==, strlen (UPLOAD_SUCCESSFUL));
+
   g_main_loop_quit (loop);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]