Ejemplo n.º 1
0
/**
 * soup_session_cancel_message:
 * @session: a #SoupSession
 * @msg: the message to cancel
 * @status_code: status code to set on @msg (generally
 * %SOUP_STATUS_CANCELLED)
 *
 * Causes @session to immediately finish processing @msg (regardless
 * of its current state) with a final status_code of @status_code. You
 * may call this at any time after handing @msg off to @session; if
 * @session has started sending the request but has not yet received
 * the complete response, then it will close the request's connection.
 * Note that with non-idempotent requests (eg, %POST, %PUT, %DELETE)
 * it is possible that you might cancel the request after the server
 * acts on it, but before it returns a response, leaving the remote
 * resource in an unknown state.
 *
 * If the message is cancelled while its response body is being read,
 * then the response body in @msg will be left partially-filled-in.
 * The response headers, on the other hand, will always be either
 * empty or complete.
 *
 * For messages queued with soup_session_queue_message() (and
 * cancelled from the same thread), the callback will be invoked
 * before soup_session_cancel_message() returns.
 **/
void
soup_session_cancel_message (SoupSession *session, SoupMessage *msg,
			     guint status_code)
{
	g_return_if_fail (SOUP_IS_SESSION (session));
	g_return_if_fail (SOUP_IS_MESSAGE (msg));

	/* If the message is already ending, don't do anything */
	if (soup_message_get_io_status (msg) == SOUP_MESSAGE_IO_STATUS_FINISHED)
		return;

	SOUP_SESSION_GET_CLASS (session)->cancel_message (session, msg, status_code);
}
Ejemplo n.º 2
0
static guint
send_message (SoupSession *session, SoupMessage *req)
{
	GMainContext *async_context =
		soup_session_get_async_context (session);

	/* Balance out the unref that final_finished will do */
	g_object_ref (req);

	queue_message (session, req, NULL, NULL);

	while (soup_message_get_io_status (req) != SOUP_MESSAGE_IO_STATUS_FINISHED &&
	       !SOUP_STATUS_IS_TRANSPORT_ERROR (req->status_code))
		g_main_context_iteration (async_context, TRUE);

	return req->status_code;
}