diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index f1e1d75..228e87e 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -709,15 +709,17 @@ struct _Multistatus {
   xmlNodePtr root;
 
   SoupURI *target;
+  char    *path;
 
 };
 
 struct _MsResponse {
 
   Multistatus *multistatus;
+  char        *path;
+  gboolean     is_target;
+  xmlNodePtr   first_propstat;
 
-  xmlNodePtr  href;
-  xmlNodePtr  first_propstat;
 };
 
 struct _MsPropstat {
@@ -733,17 +735,21 @@ struct _MsPropstat {
 static gboolean
 multistatus_parse (SoupMessage *msg, Multistatus *multistatus, GError **error)
 {
-  xmlDocPtr  doc;
-  xmlNodePtr root;
+  xmlDocPtr   doc;
+  xmlNodePtr  root;
+  SoupURI    *uri;
 
   doc = parse_xml (msg, &root, "multistatus", error);
 
   if (doc == NULL)
     return FALSE;
 
+  uri = soup_message_get_uri (msg);
+
   multistatus->doc = doc;
   multistatus->root = root;
-  multistatus->target = soup_message_get_uri (msg);
+  multistatus->target = uri;
+  multistatus->path = g_uri_unescape_string (uri->path, "/");
 
   return TRUE;
 }
@@ -752,6 +758,7 @@ static void
 multistatus_free (Multistatus *multistatus)
 {
   xmlFreeDoc (multistatus->doc);
+  g_free (multistatus->path);
 }
 
 static void
@@ -772,6 +779,9 @@ multistatus_get_response (xmlNodeIter *resp_iter, MsResponse *response)
   xmlNodePtr   iter;
   xmlNodePtr   href;
   xmlNodePtr   propstat;
+  SoupURI     *uri;
+  const char  *text;
+  char        *path;
 
   multistatus = xml_node_iter_get_user_data (resp_iter);
   resp_node = xml_node_iter_get_current (resp_iter);
@@ -805,48 +815,37 @@ multistatus_get_response (xmlNodeIter *resp_iter, MsResponse *response)
   if (href == NULL)
     return FALSE;
 
-  response->href = href;
+  text = node_get_content (href);
+
+  if (text == NULL)
+    return FALSE;
+
+  uri = soup_uri_new_with_base (multistatus->target, text);
+
+  if (uri == NULL)
+    return FALSE;
+
+  path = g_uri_unescape_string (uri->path, "/");
+  soup_uri_free (uri);
+
+  response->path = path;
+  response->is_target = path_equal (path, multistatus->path, TRUE);
   response->multistatus = multistatus;
   response->first_propstat = propstat;
 
   return resp_node != NULL;
 }
 
-static char *
-ms_response_get_basename (MsResponse *response)
+static void
+ms_response_clear (MsResponse *response)
 {
-  const char *text;
-  text = node_get_content (response->href);
-
-  return http_uri_get_basename (text);
-
+  g_free (response->path);
 }
 
-static gboolean
-ms_response_is_target (MsResponse *response)
+static char *
+ms_response_get_basename (MsResponse *response)
 {
-  const char *text;
-  SoupURI    *target;
-  SoupURI    *uri;
-  gboolean    res;
-
-  uri    = NULL;
-  target = response->multistatus->target;
-  text   = node_get_content (response->href);
-
-  if (text == NULL)
-    return FALSE;
-
-  uri = soup_uri_new_with_base (target, text);
-
-  if (uri == NULL)
-    return FALSE;
-
-  res = dav_uri_match (uri, target, TRUE);
-
-  soup_uri_free (uri);
-  
-  return res;
+  return http_path_get_basename (response->path);
 }
 
 static void
@@ -1248,13 +1247,15 @@ stat_location_finish (SoupMessage *msg,
       if (! multistatus_get_response (&iter, &response))
         continue;
 
-      if (ms_response_is_target (&response))
+      if (response.is_target)
         {
           file_type = ms_response_to_file_type (&response);
           res = TRUE;
         }
       else
         child_count++;
+
+      ms_response_clear (&response);
     }
 
   if (res)
@@ -1914,11 +1915,13 @@ do_query_info (GVfsBackend           *backend,
       if (! multistatus_get_response (&iter, &response))
         continue;
 
-      if (ms_response_is_target (&response))
+      if (response.is_target)
         {
           ms_response_to_file_info (&response, job->file_info);
           res = TRUE;
         }
+
+      ms_response_clear (&response);
     }
 
   multistatus_free (&ms);
@@ -1987,12 +1990,14 @@ do_enumerate (GVfsBackend           *backend,
       if (! multistatus_get_response (&iter, &response))
         continue;
 
-      if (ms_response_is_target (&response))
-        continue;
+      if (response.is_target == FALSE)
+	{
+	  info = g_file_info_new ();
+	  ms_response_to_file_info (&response, info);
+	  g_vfs_job_enumerate_add_info (job, info);
+	}
 
-      info = g_file_info_new ();
-      ms_response_to_file_info (&response, info);
-      g_vfs_job_enumerate_add_info (job, info);
+      ms_response_clear (&response);
     }
 
   multistatus_free (&ms);
diff --git a/daemon/gvfsbackendhttp.c b/daemon/gvfsbackendhttp.c
index 6c60e0b..a3a1186 100644
--- a/daemon/gvfsbackendhttp.c
+++ b/daemon/gvfsbackendhttp.c
@@ -144,46 +144,53 @@ http_backend_get_mount_base (GVfsBackend *backend)
 }
 
 char *
-http_uri_get_basename (const char *uri_str)
+http_path_get_basename (const char *path)
 {
-    const char *parent;
-    const char *path;
-    char       *to_free;
-    char       *basename;
-    size_t      len;
+  const char *parent;
+  char       *basename;
+  size_t      len;
+
+  if (path == NULL || *path == '\0')
+    return NULL;
 
-    if (uri_str == NULL || *uri_str == '\0')
-      return NULL;
+  /* remove any leading slashes */
+  while (*path == '/' || *path == ' ')
+    path++;
 
-    path =  uri_str;
+  len = strlen (path);
 
-    /* remove any leading slashes */
-    while (*path == '/' || *path == ' ')
-        path++;
+  if (len == 0)
+    return g_strdup ("/");
 
-    len = strlen (path);
+  /* remove any trailing slashes */
+  while (path[len - 1] == '/' || path[len - 1] == ' ')
+    len--;
 
-    if (len == 0)
-      return g_strdup ("/");
+  parent = g_strrstr_len (path, len, "/");
+
+  if (parent)
+    {
+      parent++; /* skip the found / char */
+      basename = g_strndup (parent, (len - (parent - path)));
+    }
+  else
+    basename = g_strndup (path, len);
 
-    /* remove any trailing slashes */
-    while (path[len - 1] == '/' || path[len - 1] == ' ')
-        len--;
+  return basename;
+}
 
-    parent = g_strrstr_len (path, len, "/");
+char *
+http_uri_get_basename (const char *uri_str)
+{
+  char *decoded;
+  char *basename;
 
-    if (parent)
-      {
-        parent++; /* skip the found / char */
-        to_free = g_strndup (parent, (len - (parent - path)));
-      }
-    else
-      to_free = g_strndup (path, len);
+  basename = http_path_get_basename (uri_str);
 
-    basename = soup_uri_decode (to_free);
-    g_free (to_free);
+  decoded = soup_uri_decode (basename);
+  g_free (basename);
 
-    return basename;
+  return decoded;
 }
 
 guint
diff --git a/daemon/gvfsbackendhttp.h b/daemon/gvfsbackendhttp.h
index 5cc4bd8..29b14e1 100644
--- a/daemon/gvfsbackendhttp.h
+++ b/daemon/gvfsbackendhttp.h
@@ -59,6 +59,8 @@ GType         g_vfs_backend_http_get_type    (void) G_GNUC_CONST;
 
 char *        http_uri_get_basename          (const char *uri_str);
 
+char *        http_path_get_basename         (const char *path_str);
+
 guint         http_error_code_from_status    (guint status);
 
 SoupURI *     http_backend_get_mount_base    (GVfsBackend *backend);
