From 91acb085f01b4258bc7ce750c6dfe4b8d01cdfef Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Tue, 22 Nov 2011 22:21:39 +0100 Subject: [PATCH] core: Set all headers in RygelHTTPGet Don't set Content-Length header in HEAD request for transcoded resources. This was previously caused by the message encoding being set to CONTENT_LENGTH by default. Moving the code sets the encoding to EOF causing libsoup to not set the Content-Length header. Also adds a proper Range header for byte-seek HEAD requests. This fixes the random fails of test-case 7.4.28.2,3,4,6 --- src/rygel/rygel-http-get.vala | 15 ++++++++++++++- src/rygel/rygel-http-response.vala | 12 ------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/rygel/rygel-http-get.vala b/src/rygel/rygel-http-get.vala index c830483..1427195 100644 --- a/src/rygel/rygel-http-get.vala +++ b/src/rygel/rygel-http-get.vala @@ -161,6 +161,20 @@ internal class Rygel.HTTPGet : HTTPRequest { // Add headers this.handler.add_response_headers (this); + + // Add general headers + if (this.msg.request_headers.get_one ("Range") != null) { + this.msg.set_status (Soup.KnownStatusCode.PARTIAL_CONTENT); + } else { + this.msg.set_status (Soup.KnownStatusCode.OK); + } + + if (this.seek != null && this.seek is HTTPByteSeek) { + this.msg.response_headers.set_encoding (Soup.Encoding.CONTENT_LENGTH); + } else { + this.msg.response_headers.set_encoding (Soup.Encoding.EOF); + } + debug ("Following HTTP headers appended to response:"); this.msg.response_headers.foreach ((name, value) => { debug ("%s : %s", name, value); @@ -169,7 +183,6 @@ internal class Rygel.HTTPGet : HTTPRequest { if (this.msg.method == "HEAD") { // Only headers requested, no need to send contents this.server.unpause_message (this.msg); - this.end (Soup.KnownStatusCode.OK); return; } diff --git a/src/rygel/rygel-http-response.vala b/src/rygel/rygel-http-response.vala index 5ff2ec8..bbcf655 100644 --- a/src/rygel/rygel-http-response.vala +++ b/src/rygel/rygel-http-response.vala @@ -69,18 +69,6 @@ internal class Rygel.HTTPResponse : GLib.Object, Rygel.StateMachine { this.cancellable = request_handler.cancellable; this.seek = request.seek; - if (request.msg.request_headers.get_one ("Range") != null) { - this.msg.set_status (Soup.KnownStatusCode.PARTIAL_CONTENT); - } else { - this.msg.set_status (Soup.KnownStatusCode.OK); - } - - if (this.seek != null && this.seek is HTTPByteSeek) { - this.msg.response_headers.set_encoding (Encoding.CONTENT_LENGTH); - } else { - this.msg.response_headers.set_encoding (Encoding.EOF); - } - if (this.cancellable != null) { this.cancellable.cancelled.connect (this.on_cancelled); } -- 2.7.4