[libgdata] core: GDataDownloadStream:content-length should consider Content-Range



commit 210878ba073be6bfffd3c9a6265164fbaf118f94
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Oct 2 12:41:34 2015 +0200

    core: GDataDownloadStream:content-length should consider Content-Range
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755976

 gdata/gdata-download-stream.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gdata/gdata-download-stream.c b/gdata/gdata-download-stream.c
index b43d67d..67a3514 100644
--- a/gdata/gdata-download-stream.c
+++ b/gdata/gdata-download-stream.c
@@ -814,6 +814,10 @@ gdata_download_stream_truncate (GSeekable *seekable, goffset offset, GCancellabl
 static void
 got_headers_cb (SoupMessage *message, GDataDownloadStream *self)
 {
+       goffset end;
+       goffset start;
+       goffset total_length;
+
        /* Don't get the client's hopes up by setting the Content-Type or -Length if the response
         * is actually unsuccessful. */
        if (SOUP_STATUS_IS_SUCCESSFUL (message->status_code) == FALSE)
@@ -822,6 +826,9 @@ got_headers_cb (SoupMessage *message, GDataDownloadStream *self)
        g_mutex_lock (&(self->priv->content_mutex));
        self->priv->content_type = g_strdup (soup_message_headers_get_content_type 
(message->response_headers, NULL));
        self->priv->content_length = soup_message_headers_get_content_length (message->response_headers);
+       if (soup_message_headers_get_content_range (message->response_headers, &start, &end, &total_length)) {
+               self->priv->content_length = (gssize) total_length;
+       }
        g_mutex_unlock (&(self->priv->content_mutex));
 
        /* Emit the notifications for the Content-Length and -Type properties */


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