core: Set all headers in RygelHTTPGet
authorJens Georg <mail@jensge.org>
Tue, 22 Nov 2011 21:21:39 +0000 (22:21 +0100)
committerJens Georg <mail@jensge.org>
Tue, 22 Nov 2011 21:31:27 +0000 (22:31 +0100)
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
src/rygel/rygel-http-response.vala

index c830483..1427195 100644 (file)
@@ -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;
         }
index 5ff2ec8..bbcf655 100644 (file)
@@ -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);
         }