Commit e7e602c8 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

Stop using soup_message_set_request

Use soup_message_set_request_body() or
soup_message_set_request_body_from_bytes() instead.
parent 2cebb238
......@@ -370,12 +370,13 @@ soup_form_request_for_data (const char *method, const char *uri_string,
msg = soup_message_new_from_uri (method, uri);
} else if (!strcmp (method, "POST") || !strcmp (method, "PUT")) {
GBytes *body;
msg = soup_message_new_from_uri (method, uri);
soup_message_set_request (
msg, SOUP_FORM_MIME_TYPE_URLENCODED,
SOUP_MEMORY_TAKE,
form_data, strlen (form_data));
body = g_bytes_new_take (form_data, strlen (form_data));
soup_message_set_request_body_from_bytes (msg, SOUP_FORM_MIME_TYPE_URLENCODED, body);
g_bytes_unref (body);
} else {
g_warning ("invalid method passed to soup_form_request_new");
g_free (form_data);
......
......@@ -904,8 +904,7 @@ soup_session_redirect_message (SoupSession *session, SoupMessage *msg)
SOUP_MESSAGE_METHOD, SOUP_METHOD_GET,
NULL);
}
soup_message_set_request (msg, NULL,
SOUP_MEMORY_STATIC, NULL, 0);
soup_message_set_request_body (msg, NULL, NULL, 0);
soup_message_headers_set_encoding (msg->request_headers,
SOUP_ENCODING_NONE);
}
......
......@@ -46,6 +46,13 @@ EVENT_HANDLER (wrote_headers)
EVENT_HANDLER (wrote_body)
EVENT_HANDLER (finished)
static void
restarted (SoupMessage *msg,
GBytes *body)
{
soup_message_set_request_body_from_bytes (msg, "text/plain", body);
}
static void
do_message (const char *path, gboolean long_body,
gboolean expect_continue, gboolean auth,
......@@ -59,6 +66,7 @@ do_message (const char *path, gboolean long_body,
const char *expected_event;
char *actual_event;
int expected_status, actual_status;
GBytes *request_body;
GBytes *response_body;
uri = soup_uri_copy (base_uri);
......@@ -68,11 +76,12 @@ do_message (const char *path, gboolean long_body,
}
soup_uri_set_path (uri, path);
msg = soup_message_new_from_uri ("POST", uri);
g_print ("DBG: soup_message_new_from_uri: %p\n", msg);
soup_uri_free (uri);
body = long_body ? LONG_BODY : SHORT_BODY;
soup_message_set_request (msg, "text/plain", SOUP_MEMORY_STATIC,
body, strlen (body));
request_body = g_bytes_new_static (body, strlen (body));
soup_message_set_request_body_from_bytes (msg, "text/plain", request_body);
soup_message_headers_append (msg->request_headers, "Connection", "close");
if (expect_continue) {
soup_message_headers_set_expectations (msg->request_headers,
......@@ -93,6 +102,8 @@ do_message (const char *path, gboolean long_body,
G_CALLBACK (wrote_body), "client");
g_signal_connect (msg, "finished",
G_CALLBACK (finished), "client");
g_signal_connect (msg, "restarted",
G_CALLBACK (restarted), request_body);
events = NULL;
session = soup_test_session_new (SOUP_TYPE_SESSION, NULL);
......@@ -149,6 +160,7 @@ do_message (const char *path, gboolean long_body,
!strcmp (actual_event, "server-wrote_informational"))
events = g_slist_delete_link (events, events);
}
g_bytes_unref (request_body);
g_bytes_unref (response_body);
g_object_unref (msg);
}
......@@ -158,12 +170,12 @@ do_test_unauth_short_noexpect_nopass (void)
{
do_message ("/unauth", FALSE, FALSE, FALSE,
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_CREATED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -175,12 +187,12 @@ do_test_unauth_long_noexpect_nopass (void)
{
do_message ("/unauth", TRUE, FALSE, FALSE,
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -195,11 +207,11 @@ do_test_unauth_short_expect_nopass (void)
"server-got_headers",
"server-wrote_informational", SOUP_STATUS_CONTINUE,
"client-got_informational",
"client-wrote_body",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_CREATED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -226,12 +238,12 @@ do_test_auth_short_noexpect_nopass (void)
{
do_message ("/auth", FALSE, FALSE, FALSE,
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_UNAUTHORIZED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -243,12 +255,12 @@ do_test_auth_long_noexpect_nopass (void)
{
do_message ("/auth", TRUE, FALSE, FALSE,
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_UNAUTHORIZED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -290,21 +302,21 @@ do_test_auth_short_noexpect_pass (void)
{
do_message ("/auth", FALSE, FALSE, TRUE,
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_UNAUTHORIZED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_CREATED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -316,21 +328,21 @@ do_test_auth_long_noexpect_pass (void)
{
do_message ("/auth", TRUE, FALSE, TRUE,
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_UNAUTHORIZED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-wrote_headers",
"client-wrote_body",
"server-got_headers",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......@@ -352,11 +364,11 @@ do_test_auth_short_expect_pass (void)
"server-got_headers",
"server-wrote_informational", SOUP_STATUS_CONTINUE,
"client-got_informational",
"client-wrote_body",
"server-got_body",
"server-wrote_headers", SOUP_STATUS_CREATED,
"server-wrote_body",
"server-finished",
"client-wrote_body",
"client-got_headers",
"client-got_body",
"client-finished",
......
......@@ -173,10 +173,11 @@ do_message_api_test (SoupSession *session, TestCase *test)
soup_uri_free (uri);
if (msg->method == SOUP_METHOD_POST) {
soup_message_set_request (msg, "text/plain",
SOUP_MEMORY_STATIC,
"post body",
strlen ("post body"));
GBytes *request_body;
request_body = g_bytes_new_static ("post body", strlen ("post body"));
soup_message_set_request_body_from_bytes (msg, "text/plain", request_body);
g_bytes_unref (request_body);
}
treq = &test->requests[0];
......@@ -219,10 +220,11 @@ do_request_api_test (SoupSession *session, TestCase *test)
msg = soup_request_http_get_message (reqh);
if (msg->method == SOUP_METHOD_POST) {
soup_message_set_request (msg, "text/plain",
SOUP_MEMORY_STATIC,
"post body",
strlen ("post body"));
GBytes *request_body;
request_body = g_bytes_new_static ("post body", strlen ("post body"));
soup_message_set_request_body_from_bytes (msg, "text/plain", request_body);
g_bytes_unref (request_body);
}
treq = &test->requests[0];
......
......@@ -1003,7 +1003,7 @@ do_early_stream_test (ServerData *sd, gconstpointer test_data)
msg = soup_message_new_from_uri ("POST", sd->base_uri);
index = soup_test_get_index ();
soup_message_body_append_bytes (msg->request_body, index);
soup_message_set_request_body_from_bytes (msg, "text/plain", index);
body = soup_test_session_send (session, msg, NULL, NULL);
soup_test_assert_message_status (msg, SOUP_STATUS_OK);
......@@ -1012,6 +1012,7 @@ do_early_stream_test (ServerData *sd, gconstpointer test_data)
g_assert_cmpmem (md5, strlen (md5), g_bytes_get_data (body, NULL), g_bytes_get_size (body));
g_free (md5);
g_bytes_unref (index);
g_bytes_unref (body);
g_object_unref (msg);
soup_test_session_abort_unref (session);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment