[gvfs] http: Return error if seek was not successful
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] http: Return error if seek was not successful
- Date: Thu, 26 Nov 2015 13:42:30 +0000 (UTC)
commit cb950723da8b6817dbe894fed6a78fa77c932d16
Author: Ondrej Holy <oholy redhat com>
Date: Thu Sep 10 10:38:16 2015 +0200
http: Return error if seek was not successful
Some webdav servers doesn't implement range requests, which are
necessary for a seek support. GVfsHttpInputStream doesn't handle this
case. Consequently g_seekable_tell returns a requested offset, however
g_input_stream_read returns bytes from a beginning of a file.
Return error if Content-Range header field is missing, or the range is
not valid. This change is needed to avoid data corruption when reading.
https://bugzilla.gnome.org/show_bug.cgi?id=754824
daemon/gvfshttpinputstream.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfshttpinputstream.c b/daemon/gvfshttpinputstream.c
index f96f52d..5eafc29 100644
--- a/daemon/gvfshttpinputstream.c
+++ b/daemon/gvfshttpinputstream.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <gio/gio.h>
#include <libsoup/soup.h>
@@ -353,6 +354,23 @@ read_send_callback (GObject *object,
g_object_unref (task);
return;
}
+ if (priv->range)
+ {
+ gboolean status;
+ goffset start, end;
+
+ status = soup_message_headers_get_content_range (priv->msg->response_headers,
+ &start, &end, NULL);
+ if (!status || start != priv->request_offset)
+ {
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ _("Error seeking in stream"));
+ g_object_unref (task);
+ return;
+ }
+ }
g_input_stream_read_async (priv->stream, rasd->buffer, rasd->count,
g_task_get_priority (task),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]