diff --git a/configure.ac b/configure.ac index 25bb286..be55428 100644 --- a/configure.ac +++ b/configure.ac @@ -273,11 +273,11 @@ AC_ARG_ENABLE(soup, enable_libsoup="yes") if test "$enable_libsoup" = "yes"; then - PKG_CHECK_MODULES(HTTP, libsoup-2.2 >= 2.2.0, HAVE_HTTP=yes, HAVE_HTTP=no) + PKG_CHECK_MODULES(HTTP, libsoup-2.4, HAVE_HTTP=yes, HAVE_HTTP=no) if test "x$HAVE_HTTP" = xyes; then AC_DEFINE(HAVE_HTTP, 1, [Define if libsoup is enabled]) else - AC_MSG_ERROR([Couldn't find libsoup-2.2.]) + AC_MSG_ERROR([Couldn't find libsoup-2.4.]) fi else AC_MSG_NOTICE([libsoup HTTP support was not enabled.]) diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c index 80d95c7..1c77396 100644 --- a/libswfdec-gtk/swfdec_gtk_loader.c +++ b/libswfdec-gtk/swfdec_gtk_loader.c @@ -75,22 +75,6 @@ G_DEFINE_TYPE (SwfdecGtkLoader, swfdec_gtk_loader, SWFDEC_TYPE_FILE_LOADER) #ifdef HAVE_HTTP static void -swfdec_gtk_loader_set_size (SwfdecGtkLoader *gtk) -{ - const char *s = soup_message_get_header (gtk->message->response_headers, "Content-Length"); - unsigned long l; - char *end; - - if (s == NULL) - return; - - errno = 0; - l = strtoul (s, &end, 10); - if (errno == 0 && *end == 0 && l <= G_MAXLONG) - swfdec_loader_set_size (SWFDEC_LOADER (gtk), l); -} - -static void swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk) { char *real_uri; @@ -98,22 +82,37 @@ swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk) if (gtk->opened) return; + if (soup_message_headers_get_content_length (gtk->message->response_headers)) { + swfdec_loader_set_size (SWFDEC_LOADER (gtk), + soup_message_headers_get_content_length (gtk->message->response_headers)); + } + real_uri = soup_uri_to_string (soup_message_get_uri (gtk->message), FALSE); - swfdec_gtk_loader_set_size (gtk); swfdec_loader_open (SWFDEC_LOADER (gtk), real_uri); gtk->opened = TRUE; g_free (real_uri); } static void -swfdec_gtk_loader_push (SoupMessage *msg, gpointer loader) +swfdec_gtk_loader_free_soup_buffer (unsigned char *data, gpointer chunk) +{ + soup_buffer_free (chunk); +} + +static void +swfdec_gtk_loader_push (SoupMessage *msg, SoupBuffer *chunk, gpointer loader) { SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader); SwfdecBuffer *buffer; + chunk = soup_buffer_copy (chunk); + swfdec_gtk_loader_ensure_open (gtk); - buffer = swfdec_buffer_new_and_alloc (msg->response.length); - memcpy (buffer->data, msg->response.body, msg->response.length); + buffer = swfdec_buffer_new (); + buffer->data = (unsigned char *)chunk->data; + buffer->length = chunk->length; + buffer->priv = chunk; + buffer->free = swfdec_gtk_loader_free_soup_buffer; swfdec_loader_push (loader, buffer); } @@ -168,8 +167,8 @@ swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent, g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk); g_signal_connect (gtk->message, "finished", G_CALLBACK (swfdec_gtk_loader_finished), gtk); if (data) - soup_message_set_request (gtk->message, "appliation/x-www-urlencoded", - SOUP_BUFFER_USER_OWNED, (char *) data, data_len); + soup_message_set_request (gtk->message, "application/x-www-form-urlencoded", + SOUP_MEMORY_COPY, (char *) data, data_len); g_object_ref (gtk->message); soup_session_queue_message (klass->session, gtk->message, NULL, NULL); } @@ -189,7 +188,7 @@ swfdec_gtk_loader_close (SwfdecLoader *loader) if (!eof) { SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk); - soup_session_cancel_message (klass->session, gtk->message); + soup_session_cancel_message (klass->session, gtk->message, SOUP_STATUS_CANCELLED); g_object_unref (gtk->message); gtk->message = NULL; }