gvfs r1139 - in trunk: . daemon



Author: gicmo
Date: Wed Jan 16 12:24:53 2008
New Revision: 1139
URL: http://svn.gnome.org/viewvc/gvfs?rev=1139&view=rev

Log:
2008-01-16  Christian Kellner  <gicmo gnome org>

	* daemon/gvfsbackenddav.c: 
	* daemon/gvfsbackendhttp.c:
	* daemon/gvfsbackendhttp.h:
	* daemon/soup-input-stream.c:
	* daemon/soup-output-stream.c:
	Port to libsoup-2.4.

	* configure.ac:
	* daemon/Makefile.am:
	Make building of http optional (and depend on wether
	libsoup is found or not)


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/daemon/Makefile.am
   trunk/daemon/gvfsbackenddav.c
   trunk/daemon/gvfsbackendhttp.c
   trunk/daemon/gvfsbackendhttp.h
   trunk/daemon/soup-input-stream.c
   trunk/daemon/soup-output-stream.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed Jan 16 12:24:53 2008
@@ -51,9 +51,7 @@
 DBUS_SERVICE_DIR=$with_dbus_service_dir
 AC_SUBST(DBUS_SERVICE_DIR)
 
-PKG_CHECK_MODULES(HTTP, libsoup-2.2 >= 2.2.104)
-AC_SUBST(HTTP_CFLAGS)
-AC_SUBST(HTTP_LIBS)
+
 
 dnl ****************************
 dnl *** Checks for intltool  ***
@@ -113,6 +111,27 @@
 AC_SEARCH_LIBS(login_tty, util, [AC_DEFINE([HAVE_LOGIN_TTY],[],[Whether login_tty is available])])
 
 dnl **************************************************
+dnl *** Check if we should build with http backend ***
+dnl **************************************************
+AC_ARG_ENABLE(http, [  --disable-http           build without http/dav backend])
+msg_http=no
+HTTP_CFLAGS=
+HTTP_LIBS=
+
+if test "x$enable_http" != "xno"; then
+  PKG_CHECK_EXISTS(libsoup-2.4 >= 2.3.0, msg_http=yes)
+
+  if test "x$msg_http" == "xyes"; then
+    PKG_CHECK_MODULES(HTTP, libsoup-2.4)
+    AC_DEFINE(HAVE_HTTP, 1, [Define to 1 if http/dav is going to be built])
+  fi
+fi
+
+AC_SUBST(HTTP_CFLAGS)
+AC_SUBST(HTTP_LIBS)
+AM_CONDITIONAL(HAVE_HTTP, [test "$msg_http" = "yes"])
+
+dnl **************************************************
 dnl *** Check if we should build with CDDA backend ***
 dnl **************************************************
 AC_ARG_ENABLE(cdda, [  --disable-cdda           build without CDDA backend])
@@ -320,6 +339,7 @@
 echo 
 echo "gvfs configuration summary:"
 echo "
+        HTTP/WebDAV support           $msg_http
 	Samba support:	              $msg_samba
 	FUSE support:                 $msg_fuse
         CDDA support:                 $msg_cdda

Modified: trunk/daemon/Makefile.am
==============================================================================
--- trunk/daemon/Makefile.am	(original)
+++ trunk/daemon/Makefile.am	Wed Jan 16 12:24:53 2008
@@ -30,10 +30,16 @@
 %.mount: %.mount.in ../config.log
 	sed -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
 
-libexec_PROGRAMS=gvfsd gvfsd-ftp gvfsd-sftp gvfsd-http gvfsd-dav gvfsd-trash gvfsd-computer gvfsd-localtest
+libexec_PROGRAMS=gvfsd gvfsd-ftp gvfsd-sftp gvfsd-trash gvfsd-computer gvfsd-localtest
 
-mount_in_files = ftp.mount.in sftp.mount.in http.mount.in dav.mount.in trash.mount.in computer.mount.in localtest.mount.in
-mount_DATA = ftp.mount sftp.mount trash.mount http.mount dav.mount computer.mount localtest.mount
+mount_in_files = ftp.mount.in sftp.mount.in trash.mount.in computer.mount.in localtest.mount.in
+mount_DATA = ftp.mount sftp.mount trash.mount computer.mount localtest.mount
+
+if HAVE_HTTP
+mount_in_files += http.mount.in dav.mount.in 
+mount_DATA += http.mount dav.mount  
+libexec_PROGRAMS += gvfsd-http gvfsd-dav
+endif
 
 if HAVE_SAMBA
 mount_in_files += smb.mount.in smb-browse.mount.in

Modified: trunk/daemon/gvfsbackenddav.c
==============================================================================
--- trunk/daemon/gvfsbackenddav.c	(original)
+++ trunk/daemon/gvfsbackenddav.c	Wed Jan 16 12:24:53 2008
@@ -35,8 +35,6 @@
 #include <gio/gio.h>
 
 #include <libsoup/soup.h>
-#include <libsoup/soup-headers.h>
-#include <libsoup/soup-uri.h>
 
 /* LibXML2 includes */
 #include <libxml/parser.h>
@@ -95,28 +93,17 @@
 static inline gboolean
 sm_has_header (SoupMessage *msg, const char *header)
 {
-  return soup_message_get_header (msg->response_headers, header) != NULL;
-}
-
-static inline guint
-soup_protocol_default_port (SoupProtocol proto)
-{
-	if (proto == SOUP_PROTOCOL_HTTP)
-		return 80;
-	else if (proto == SOUP_PROTOCOL_HTTPS)
-		return 443;
-	else
-		return 0;
+  return soup_message_headers_get (msg->response_headers, header) != NULL;
 }
 
 /* ************************************************************************* */
 /*  */
 
 static inline void
-send_message (GVfsBackend           *backend,
-              SoupMessage           *message, 
-              SoupMessageCallbackFn  callback,
-              gpointer               user_data)
+send_message (GVfsBackend         *backend,
+              SoupMessage         *message, 
+              SoupSessionCallback  callback,
+              gpointer             user_data)
 {
 
   soup_session_queue_message (G_VFS_BACKEND_HTTP (backend)->session,
@@ -130,13 +117,13 @@
                            const char  *filename)
 {
   SoupMessage *msg;
-  SoupUri     *uri;
+  SoupURI     *uri;
 
   uri = g_vfs_backend_uri_for_filename (backend, filename);
   msg = soup_message_new_from_uri (method, uri);
   soup_uri_free (uri);
 
-  soup_message_add_header (msg->request_headers,
+  soup_message_headers_append (msg->request_headers,
                            "User-Agent", "gvfs/" VERSION);
   return msg;
 }
@@ -156,8 +143,8 @@
       return NULL;
     }
 
-  doc = xmlReadMemory (msg->response.body,
-                       msg->response.length,
+  doc = xmlReadMemory (msg->response_body->data,
+                       msg->response_body->length,
                        "response.xml",
                        NULL,
                        0);
@@ -271,7 +258,7 @@
 static GFileInfo *
 multistatus_parse_response (xmlDocPtr    doc,
                             xmlNodePtr   resp,
-                            SoupUri     *base)
+                            SoupURI     *base)
 {
   GFileInfo  *info;
   xmlNodePtr  node;
@@ -433,7 +420,7 @@
 {
   GVfsBackendDav *backend;
   GVfsJobMount   *job;
-  SoupUri        *mount_base;
+  SoupURI        *mount_base;
   gboolean        res;
   gboolean        aborted;
   char           *prompt;
@@ -515,7 +502,8 @@
                      user_data);
 }
 
-static void discover_mount_root_ready (SoupMessage *msg,
+static void discover_mount_root_ready (SoupSession *session,
+                                       SoupMessage *msg,
                                        gpointer     user_data);
 static void
 discover_mount_root (GVfsBackendDav *backend, GVfsJobMount *job)
@@ -523,25 +511,26 @@
   GVfsBackendHttp *http_backend;
   SoupMessage     *msg;
   SoupSession     *session;
-  SoupUri         *mount_base;
+  SoupURI         *mount_base;
 
   http_backend = G_VFS_BACKEND_HTTP (backend);
   mount_base = http_backend->mount_base;
   session = http_backend->session;
 
   msg = soup_message_new_from_uri (SOUP_METHOD_OPTIONS, mount_base);
-  soup_message_add_header (msg->request_headers, "User-Agent", "gvfs/" VERSION);
+  soup_message_headers_append (msg->request_headers, "User-Agent", "gvfs/" VERSION);
   soup_session_queue_message (session, msg, discover_mount_root_ready, job);
 }
 
 static void
-discover_mount_root_ready (SoupMessage *msg,
+discover_mount_root_ready (SoupSession *session,
+                           SoupMessage *msg,
                            gpointer     user_data)
 {
   GVfsBackendDav *backend;
   GVfsJobMount   *job;
   GMountSpec     *mount_spec;
-  SoupUri        *mount_base;
+  SoupURI        *mount_base;
   gboolean        is_success;
   gboolean        is_dav;
 
@@ -599,9 +588,9 @@
   if (mount_base->user)
     g_mount_spec_set (mount_spec, "user", mount_base->user);
 
-  if (mount_base->protocol == SOUP_PROTOCOL_HTTP)
+  if (mount_base->scheme == SOUP_URI_SCHEME_HTTP)
     g_mount_spec_set (mount_spec, "ssl", "false");
-  else if (mount_base->protocol == SOUP_PROTOCOL_HTTPS)
+  else if (mount_base->scheme == SOUP_URI_SCHEME_HTTPS)
     g_mount_spec_set (mount_spec, "ssl", "true");
 
   g_free (mount_base->path);
@@ -652,7 +641,7 @@
            gboolean      is_automount)
 {
   GVfsBackendDav *op_backend;
-  SoupUri        *uri;
+  SoupURI        *uri;
   const char     *host;
   const char     *user;
   const char     *port;
@@ -681,22 +670,20 @@
       return TRUE;
     }
 
-  uri = g_new0 (SoupUri, 1);
+  uri = soup_uri_new (NULL);
 
   if (ssl != NULL && (strcmp (ssl, "true") == 0))
-    uri->protocol = SOUP_PROTOCOL_HTTPS;
+    soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS);
   else
-    uri->protocol = SOUP_PROTOCOL_HTTP;
-  
-  uri->user = g_strdup (user);
+    soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
+
+  soup_uri_set_user (uri, user);
 
   if (port && (port_num = atoi (port)))
-    uri->port = port_num;
-  else
-    uri->port = soup_protocol_default_port (uri->protocol);
+    soup_uri_set_port (uri, port_num);
 
-  uri->host = g_strdup (host);
-  uri->path = g_strdup (mount_spec->mount_prefix);
+  soup_uri_set_host (uri, host);
+  soup_uri_set_path (uri, mount_spec->mount_prefix);
 
   G_VFS_BACKEND_HTTP (backend)->mount_base = uri; 
 
@@ -704,12 +691,13 @@
 }
 
 static void
-query_info_ready (SoupMessage *msg,
+query_info_ready (SoupSession *session,
+                  SoupMessage *msg,
                   gpointer     user_data)
 {
   GVfsBackendDav    *backend;
   GVfsJobQueryInfo  *job;
-  SoupUri           *base;
+  SoupURI           *base;
   GFileInfo         *info;
   GError            *error;
   xmlDocPtr          doc;
@@ -789,7 +777,7 @@
       return TRUE;
     }
 
-  soup_message_add_header (msg->request_headers, "Depth", "0");
+  soup_message_headers_append (msg->request_headers, "Depth", "0");
 
   /* RFC 4437 */
   if (flags & G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS)
@@ -797,11 +785,11 @@
   else
       redirect_header = "T";
 
-  soup_message_add_header (msg->request_headers,
+  soup_message_headers_append (msg->request_headers,
                            "Apply-To-Redirect-Ref", redirect_header);
 
   soup_message_set_request (msg, "application/xml",
-                            SOUP_BUFFER_SYSTEM_OWNED,
+                            SOUP_MEMORY_TAKE,
                             request,
                             len);
 
@@ -814,12 +802,13 @@
 
 
 static void
-enumerate_ready (SoupMessage *msg,
+enumerate_ready (SoupSession *session,
+                 SoupMessage *msg,
                  gpointer     user_data)
 {
   GVfsBackendDav    *backend;
   GVfsJobEnumerate  *job;
-  SoupUri           *base;
+  SoupURI           *base;
   GFileInfo         *info;
   GError            *error;
   xmlDocPtr          doc;
@@ -903,7 +892,7 @@
       return TRUE;
     }
 
-  soup_message_add_header (msg->request_headers, "Depth", "1");
+  soup_message_headers_append (msg->request_headers, "Depth", "1");
 
   /* RFC 4437 */
   if (flags & G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS)
@@ -911,11 +900,11 @@
   else
       redirect_header = "T";
 
-  soup_message_add_header (msg->request_headers,
+  soup_message_headers_append (msg->request_headers,
                            "Apply-To-Redirect-Ref", redirect_header);
 
   soup_message_set_request (msg, "application/xml",
-                            SOUP_BUFFER_SYSTEM_OWNED,
+                            SOUP_MEMORY_TAKE,
                             request,
                             len);
 

Modified: trunk/daemon/gvfsbackendhttp.c
==============================================================================
--- trunk/daemon/gvfsbackendhttp.c	(original)
+++ trunk/daemon/gvfsbackendhttp.c	Wed Jan 16 12:24:53 2008
@@ -83,11 +83,11 @@
   backend->session = soup_session_async_new ();
 }
 
-SoupUri *
+SoupURI *
 g_vfs_backend_uri_for_filename (GVfsBackend *backend, const char *filename)
 {
   GVfsBackendHttp *op_backend;
-  SoupUri         *uri;
+  SoupURI         *uri;
   char            *path;
 
   op_backend = G_VFS_BACKEND_HTTP (backend);
@@ -101,8 +101,8 @@
    * be a directory in this case).
    */
   path = g_build_path ("/", uri->path, filename, NULL);
-  g_free (uri->path);
-  uri->path = path;
+  soup_uri_set_path (uri, path);
+  g_free (path);
 
   return uri;
 }
@@ -117,7 +117,7 @@
 {
   GVfsBackendHttp *op_backend;
   const char      *uri_str;
-  SoupUri         *uri;
+  SoupURI         *uri;
   GMountSpec      *real_mount_spec;
 
   op_backend = G_VFS_BACKEND_HTTP (backend);
@@ -193,7 +193,7 @@
 {
   GVfsBackendHttp *op_backend;
   GInputStream    *stream;
-  SoupUri         *uri;
+  SoupURI         *uri;
   SoupMessage     *msg;
 
   op_backend = G_VFS_BACKEND_HTTP (backend);
@@ -201,7 +201,7 @@
 
   msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
   soup_uri_free (uri);
-  soup_message_add_header (msg->request_headers, "User-Agent", "gvfs/" VERSION);
+  soup_message_headers_append (msg->request_headers, "User-Agent", "gvfs/" VERSION);
 
   stream = soup_input_stream_new (op_backend->session, msg);
   g_object_unref (msg);
@@ -356,7 +356,8 @@
 
 /* *** create () *** */
 static void
-try_create_tested_existence (SoupMessage *msg, gpointer user_data)
+try_create_tested_existence (SoupSession *session, SoupMessage *msg,
+                             gpointer user_data)
 {
   GVfsJob *job = G_VFS_JOB (user_data);
   GVfsBackendHttp *op_backend = job->backend_data;
@@ -375,8 +376,8 @@
 
   put_msg = soup_message_new_from_uri (SOUP_METHOD_PUT,
                                        soup_message_get_uri (msg));
-  soup_message_add_header (put_msg->request_headers, "User-Agent", "gvfs/" VERSION);
-  soup_message_add_header (put_msg->request_headers, "If-None-Match", "*");
+  soup_message_headers_append (put_msg->request_headers, "User-Agent", "gvfs/" VERSION);
+  soup_message_headers_append (put_msg->request_headers, "If-None-Match", "*");
   stream = soup_output_stream_new (op_backend->session, put_msg, -1);
   g_object_unref (put_msg);
 
@@ -391,7 +392,7 @@
             GFileCreateFlags flags)
 {
   GVfsBackendHttp *op_backend;
-  SoupUri         *uri;
+  SoupURI         *uri;
   SoupMessage     *msg;
 
   /* FIXME: if SoupOutputStream supported chunked requests, we could
@@ -403,7 +404,7 @@
 
   msg = soup_message_new_from_uri (SOUP_METHOD_HEAD, uri);
   soup_uri_free (uri);
-  soup_message_add_header (msg->request_headers, "User-Agent", "gvfs/" VERSION);
+  soup_message_headers_append (msg->request_headers, "User-Agent", "gvfs/" VERSION);
 
   g_vfs_job_set_backend_data (G_VFS_JOB (job), op_backend, NULL);
   soup_session_queue_message (op_backend->session, msg,
@@ -414,15 +415,15 @@
 /* *** replace () *** */
 static void
 open_for_replace_succeeded (GVfsBackendHttp *op_backend, GVfsJob *job,
-                            const SoupUri *uri, const char *etag)
+                            SoupURI *uri, const char *etag)
 {
   SoupMessage     *put_msg;
   GOutputStream   *stream;
 
   put_msg = soup_message_new_from_uri (SOUP_METHOD_PUT, uri);
-  soup_message_add_header (put_msg->request_headers, "User-Agent", "gvfs/" VERSION);
+  soup_message_headers_append (put_msg->request_headers, "User-Agent", "gvfs/" VERSION);
   if (etag)
-    soup_message_add_header (put_msg->request_headers, "If-Match", etag);
+    soup_message_headers_append (put_msg->request_headers, "If-Match", etag);
 
   stream = soup_output_stream_new (op_backend->session, put_msg, -1);
   g_object_unref (put_msg);
@@ -432,7 +433,8 @@
 }
 
 static void
-try_replace_checked_etag (SoupMessage *msg, gpointer user_data)
+try_replace_checked_etag (SoupSession *session, SoupMessage *msg,
+                          gpointer user_data)
 {
   GVfsJob *job = G_VFS_JOB (user_data);
   GVfsBackendHttp *op_backend = job->backend_data;
@@ -448,7 +450,7 @@
   /* FIXME: other errors */
 
   open_for_replace_succeeded (op_backend, job, soup_message_get_uri (msg),
-                              soup_message_get_header (msg->request_headers, "If-Match"));
+                              soup_message_headers_get (msg->request_headers, "If-Match"));
 }  
 
 static gboolean
@@ -460,7 +462,7 @@
              GFileCreateFlags flags)
 {
   GVfsBackendHttp *op_backend;
-  SoupUri         *uri;
+  SoupURI         *uri;
 
   /* FIXME: if SoupOutputStream supported chunked requests, we could
    * use a PUT with "If-Match: ..." and "Expect: 100-continue"
@@ -485,8 +487,8 @@
 
       msg = soup_message_new_from_uri (SOUP_METHOD_HEAD, uri);
       soup_uri_free (uri);
-      soup_message_add_header (msg->request_headers, "User-Agent", "gvfs/" VERSION);
-      soup_message_add_header (msg->request_headers, "If-Match", etag);
+      soup_message_headers_append (msg->request_headers, "User-Agent", "gvfs/" VERSION);
+      soup_message_headers_append (msg->request_headers, "If-Match", etag);
 
       g_vfs_job_set_backend_data (G_VFS_JOB (job), op_backend, NULL);
       soup_session_queue_message (op_backend->session, msg,

Modified: trunk/daemon/gvfsbackendhttp.h
==============================================================================
--- trunk/daemon/gvfsbackendhttp.h	(original)
+++ trunk/daemon/gvfsbackendhttp.h	Wed Jan 16 12:24:53 2008
@@ -48,12 +48,12 @@
 {
   GVfsBackend parent_instance;
 
-  SoupUri     *mount_base;
+  SoupURI     *mount_base;
   SoupSession *session;
 };
 
 GType        g_vfs_backend_http_get_type    (void) G_GNUC_CONST;
-SoupUri *    g_vfs_backend_uri_for_filename (GVfsBackend *backend, const char *filename);
+SoupURI *    g_vfs_backend_uri_for_filename (GVfsBackend *backend, const char *filename);
 G_END_DECLS
 
 #endif /* __G_VFS_BACKEND_HTTP_H__ */

Modified: trunk/daemon/soup-input-stream.c
==============================================================================
--- trunk/daemon/soup-input-stream.c	(original)
+++ trunk/daemon/soup-input-stream.c	Wed Jan 16 12:24:53 2008
@@ -41,7 +41,7 @@
   SoupSession *session;
   GMainContext *async_context;
   SoupMessage *msg;
-  gboolean got_headers;
+  gboolean got_headers, finished;
   goffset offset;
 
   GCancellable *cancellable;
@@ -106,7 +106,7 @@
 						GError              **error);
 
 static void soup_input_stream_got_headers (SoupMessage *msg, gpointer stream);
-static void soup_input_stream_got_chunk (SoupMessage *msg, gpointer stream);
+static void soup_input_stream_got_chunk (SoupMessage *msg, SoupBuffer *chunk, gpointer stream);
 static void soup_input_stream_finished (SoupMessage *msg, gpointer stream);
 
 static void
@@ -163,6 +163,18 @@
   ;
 }
 
+static void
+soup_input_stream_queue_message (SoupInputStream *stream)
+{
+  SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
+
+  priv->got_headers = priv->finished = FALSE;
+
+  /* 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);
+}
+
 /**
  * soup_input_stream_new:
  * @session: the #SoupSession to use
@@ -212,10 +224,7 @@
   g_signal_connect (msg, "finished",
 		    G_CALLBACK (soup_input_stream_finished), stream);
 
-  /* Add an extra ref since soup_session_queue_message steals one */
-  g_object_ref (msg);
-  soup_session_queue_message (session, msg, NULL, NULL);
-
+  soup_input_stream_queue_message (stream);
   return G_INPUT_STREAM (stream);
 }
 
@@ -236,7 +245,7 @@
   if (!priv->caller_buffer)
     {
       /* Not ready to read the body yet */
-      soup_message_io_pause (msg);
+      soup_session_pause_message (priv->session, msg);
     }
 
   if (priv->got_headers_cb)
@@ -244,11 +253,12 @@
 }
 
 static void
-soup_input_stream_got_chunk (SoupMessage *msg, gpointer stream)
+soup_input_stream_got_chunk (SoupMessage *msg, SoupBuffer *chunk_buffer,
+			     gpointer stream)
 {
   SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
-  gchar *chunk = msg->response.body;
-  gsize chunk_size = msg->response.length;
+  const gchar *chunk = chunk_buffer->data;
+  gsize chunk_size = chunk_buffer->length;
 
   /* We only pay attention to the chunk if it's part of a successful
    * response.
@@ -293,7 +303,7 @@
 	}
     }
 
-  soup_message_io_pause (msg);
+  soup_session_pause_message (priv->session, msg);
   if (priv->got_chunk_cb)
     priv->got_chunk_cb (stream);
 }
@@ -303,6 +313,8 @@
 {
   SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
 
+  priv->finished = TRUE;
+
   if (priv->finished_cb)
     priv->finished_cb (stream);
 }
@@ -315,7 +327,7 @@
 
   priv->cancel_watch = NULL;
 
-  soup_message_io_pause (priv->msg);
+  soup_session_pause_message (priv->session, priv->msg);
   if (priv->cancelled_cb)
     priv->cancelled_cb (stream);
 
@@ -347,8 +359,8 @@
   priv->caller_bufsize = count;
   priv->caller_nread = 0;
 
-  if (priv->msg->status == SOUP_MESSAGE_STATUS_RUNNING)
-    soup_message_io_unpause (priv->msg);
+  if (priv->got_headers)
+    soup_session_unpause_message (priv->session, priv->msg);
 }
 
 static void
@@ -417,8 +429,7 @@
   SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
 
   soup_input_stream_prepare_for_io (stream, cancellable, NULL, 0);
-  while (priv->msg->status != SOUP_MESSAGE_STATUS_FINISHED &&
-	 !priv->got_headers &&
+  while (!priv->finished && !priv->got_headers &&
 	 !g_cancellable_is_cancelled (cancellable))
     g_main_context_iteration (priv->async_context, TRUE);
   soup_input_stream_done_io (stream);
@@ -472,7 +483,7 @@
 {
   SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
 
-  if (priv->msg->status == SOUP_MESSAGE_STATUS_FINISHED)
+  if (priv->finished)
     return 0;
 
   /* If there is data leftover from a previous read, return it. */
@@ -481,8 +492,7 @@
 
   /* No leftover data, accept one chunk from the network */
   soup_input_stream_prepare_for_io (stream, cancellable, buffer, count);
-  while (priv->msg->status != SOUP_MESSAGE_STATUS_FINISHED &&
-	 priv->caller_nread == 0 &&
+  while (!priv->finished && priv->caller_nread == 0 &&
 	 !g_cancellable_is_cancelled (cancellable))
     g_main_context_iteration (priv->async_context, TRUE);
   soup_input_stream_done_io (stream);
@@ -505,11 +515,8 @@
 {
   SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
 
-  if (priv->msg->status != SOUP_MESSAGE_STATUS_FINISHED)
-    {
-      soup_message_set_status (priv->msg, SOUP_STATUS_CANCELLED);
-      soup_session_cancel_message (priv->session, priv->msg);
-    }
+  if (!priv->finished)
+    soup_session_cancel_message (priv->session, priv->msg, SOUP_STATUS_CANCELLED);
 
   return TRUE;
 }
@@ -730,7 +737,7 @@
 				      callback, user_data,
 				      soup_input_stream_read_async);
 
-  if (priv->msg->status == SOUP_MESSAGE_STATUS_FINISHED)
+  if (priv->finished)
     {
       g_simple_async_result_set_op_res_gssize (result, 0);
       g_simple_async_result_complete_in_idle (result);
@@ -831,8 +838,8 @@
   if (!g_input_stream_set_pending (stream, error))
       return FALSE;
 
-  if (priv->msg->status != SOUP_MESSAGE_STATUS_FINISHED)
-    soup_session_cancel_message (priv->session, priv->msg);
+  soup_session_cancel_message (priv->session, priv->msg, SOUP_STATUS_CANCELLED);
+  soup_message_io_cleanup (priv->msg);
 
   switch (type)
     {
@@ -858,14 +865,11 @@
       g_return_val_if_reached (FALSE);
     }
 
-  soup_message_remove_header (priv->msg->request_headers, "Range");
-  soup_message_add_header (priv->msg->request_headers, "Range", range);
+  soup_message_headers_remove (priv->msg->request_headers, "Range");
+  soup_message_headers_append (priv->msg->request_headers, "Range", range);
   g_free (range);
 
-  soup_session_cancel_message (priv->session, priv->msg);
-  soup_message_io_cleanup (priv->msg);
-  g_object_ref (priv->msg);
-  soup_session_queue_message (priv->session, priv->msg, NULL, NULL);
+  soup_input_stream_queue_message (SOUP_INPUT_STREAM (stream));
 
   g_input_stream_clear_pending (stream);
   return TRUE;

Modified: trunk/daemon/soup-output-stream.c
==============================================================================
--- trunk/daemon/soup-output-stream.c	(original)
+++ trunk/daemon/soup-output-stream.c	Wed Jan 16 12:24:53 2008
@@ -38,6 +38,7 @@
   SoupSession *session;
   GMainContext *async_context;
   SoupMessage *msg;
+  gboolean finished;
 
   goffset size, offset;
   GByteArray *ba;
@@ -184,7 +185,7 @@
 
   priv->cancel_watch = NULL;
 
-  soup_message_io_pause (priv->msg);
+  soup_session_pause_message (priv->session, priv->msg);
   if (priv->cancelled_cb)
     priv->cancelled_cb (stream);
 
@@ -198,9 +199,8 @@
   int cancel_fd;
 
   /* Move the buffer to the SoupMessage */
-  priv->msg->request.body = (char *)priv->ba->data;
-  priv->msg->request.length = priv->ba->len;
-  priv->msg->request.owner = SOUP_BUFFER_SYSTEM_OWNED;
+  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;
 
@@ -281,8 +281,7 @@
   }
 
   soup_output_stream_prepare_for_io (stream, cancellable);
-  while (priv->msg->status != SOUP_MESSAGE_STATUS_FINISHED &&
-	 !g_cancellable_is_cancelled (cancellable))
+  while (!priv->finished && !g_cancellable_is_cancelled (cancellable))
     g_main_context_iteration (priv->async_context, TRUE);
   soup_output_stream_done_io (stream);
 
@@ -370,6 +369,8 @@
 {
   SoupOutputStreamPrivate *priv = SOUP_OUTPUT_STREAM_GET_PRIVATE (stream);
 
+  priv->finished = TRUE;
+
   g_signal_handlers_disconnect_by_func (priv->msg, G_CALLBACK (soup_output_stream_finished), stream);
   close_async_done (stream);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]