static gboolean soup_input_stream_seek (GSeekable *seekable, goffset offset, GSeekType type, GCancellable *cancellable, GError **error) { GInputStream *stream = G_INPUT_STREAM (seekable); SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (seekable); char *range; if (type == G_SEEK_END) { /* FIXME: we could send "bytes=-offset", but unless we know the * Content-Length, we wouldn't be able to answer a tell() properly. * We could find the Content-Length by doing a HEAD... */ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "G_SEEK_END not currently supported"); return FALSE; } if (!g_input_stream_set_pending (stream, error)) return FALSE; soup_session_cancel_message (priv->session, priv->msg, SOUP_STATUS_CANCELLED); soup_message_io_cleanup (priv->msg); switch (type) { case G_SEEK_CUR: offset += priv->offset; /* fall through */ case G_SEEK_SET: range = g_strdup_printf ("bytes=%"G_GUINT64_FORMAT"-", (guint64)offset); priv->offset = offset; break; case G_SEEK_END: range = NULL; /* keep compilers happy */ g_return_val_if_reached (FALSE); break; default: g_return_val_if_reached (FALSE); } soup_message_headers_remove (priv->msg->request_headers, "Range"); soup_message_headers_append (priv->msg->request_headers, "Range", range); g_free (range); soup_input_stream_queue_message (SOUP_INPUT_STREAM (stream)); g_input_stream_clear_pending (stream); return TRUE; }
static void wrapper_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { GInputStream *stream = G_INPUT_STREAM (source_object); SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream); g_input_stream_clear_pending (stream); if (priv->outstanding_callback) (*priv->outstanding_callback) (source_object, res, user_data); priv->outstanding_callback = NULL; g_object_unref (stream); }
/** * soup_input_stream_send: * @stream: a #SoupInputStream * @cancellable: optional #GCancellable object, %NULL to ignore. * @error: location to store the error occuring, or %NULL to ignore * * Synchronously sends the HTTP request associated with @stream, and * reads the response headers. Call this after soup_input_stream_new() * and before the first g_input_stream_read() if you want to check the * HTTP status code before you start reading. * * Return value: %TRUE if msg has a successful (2xx) status, %FALSE if * not. **/ gboolean soup_input_stream_send (GInputStream *stream, GCancellable *cancellable, GError **error) { gboolean result; g_return_val_if_fail (SOUP_IS_INPUT_STREAM (stream), FALSE); if (!g_input_stream_set_pending (stream, error)) return FALSE; result = soup_input_stream_send_internal (stream, cancellable, error); g_input_stream_clear_pending (stream); return result; }
static void ekg_connection_remove(struct ekg_connection *c) { if (g_input_stream_has_pending(G_INPUT_STREAM(c->instream))) { debug_warn("ekg_connection_remove(%x) input stream has pending!\n", c); g_input_stream_clear_pending(G_INPUT_STREAM(c->instream)); } #if 0 /* XXX */ g_assert(!g_output_stream_has_pending( G_OUTPUT_STREAM(c->outstream))); #endif connections = g_slist_remove(connections, c); g_string_free(c->wr_buffer, TRUE); g_object_unref(c->cancellable); g_object_unref(c->instream); g_object_unref(c->outstream); g_slice_free(struct ekg_connection, c); }