static void soup_input_stream_prepare_for_io (GInputStream *stream, GCancellable *cancellable, guchar *buffer, gsize count) { SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream); int cancel_fd; priv->cancellable = cancellable; cancel_fd = g_cancellable_get_fd (cancellable); if (cancel_fd != -1) { GIOChannel *chan = g_io_channel_unix_new (cancel_fd); priv->cancel_watch = soup_add_io_watch (priv->async_context, chan, G_IO_IN | G_IO_ERR | G_IO_HUP, soup_input_stream_cancelled, stream); g_io_channel_unref (chan); } priv->caller_buffer = buffer; priv->caller_bufsize = count; priv->caller_nread = 0; if (priv->got_headers) soup_session_unpause_message (priv->session, priv->msg); }
static void soup_output_stream_prepare_for_io (GOutputStream *stream, GCancellable *cancellable) { SoupOutputStreamPrivate *priv = SOUP_OUTPUT_STREAM_GET_PRIVATE (stream); int cancel_fd; /* Move the buffer to the SoupMessage */ soup_message_body_append (priv->msg->request_body, SOUP_MEMORY_TAKE, priv->ba->data, priv->ba->len); g_byte_array_free (priv->ba, FALSE); priv->ba = NULL; /* Set up cancellation */ priv->cancellable = cancellable; cancel_fd = g_cancellable_get_fd (cancellable); if (cancel_fd != -1) { GIOChannel *chan = g_io_channel_unix_new (cancel_fd); priv->cancel_watch = soup_add_io_watch (priv->async_context, chan, G_IO_IN | G_IO_ERR | G_IO_HUP, soup_output_stream_cancelled, stream); g_io_channel_unref (chan); } /* Add an extra ref since soup_session_queue_message steals one */ g_object_ref (priv->msg); soup_session_queue_message (priv->session, priv->msg, NULL, NULL); }