HTTPResponse.end takes HTTP status code to put on the message.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Sun, 18 Jan 2009 19:27:54 +0000 (19:27 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Sun, 18 Jan 2009 19:27:54 +0000 (19:27 +0000)
This is to allow the users/subclasses to be always able to end the stream
using the same single method.

svn path=/trunk/; revision=451

src/rygel/rygel-http-response.vala
src/rygel/rygel-interactive-response.vala
src/rygel/rygel-streaming-response.vala

index 5641c9b..c971396 100644 (file)
@@ -53,7 +53,7 @@ public class Rygel.HTTPResponse : GLib.Object {
                                      Soup.ClientContext client) {
         // Ignore if message isn't ours
         if (msg == this.msg)
-            this.end (true);
+            this.end (true, Soup.KnownStatusCode.NONE);
     }
 
     public void set_mime_type (string mime_type) {
@@ -68,7 +68,11 @@ public class Rygel.HTTPResponse : GLib.Object {
         this.server.unpause_message (this.msg);
     }
 
-    public virtual void end (bool aborted) {
+    public virtual void end (bool aborted, uint status) {
+        if (status != Soup.KnownStatusCode.NONE) {
+            this.msg.set_status (status);
+        }
+
         this.ended ();
     }
 }
index 6dd69f8..8d78eb5 100644 (file)
@@ -66,7 +66,7 @@ public class Rygel.InteractiveResponse : Rygel.HTTPResponse {
             warning ("Failed to read from URI: %s: %s\n",
                      file.get_uri (),
                      err.message);
-            this.msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
+            this.end (false, Soup.KnownStatusCode.NOT_FOUND);
             return;
         }
 
@@ -79,8 +79,8 @@ public class Rygel.InteractiveResponse : Rygel.HTTPResponse {
                          seek.stop.to_string (),
                          file.get_uri (),
                          err.message);
-                this.msg.set_status (
-                         Soup.KnownStatusCode.REQUESTED_RANGE_NOT_SATISFIABLE);
+                this.end (false,
+                          Soup.KnownStatusCode.REQUESTED_RANGE_NOT_SATISFIABLE);
                 return;
             }
         }
@@ -104,12 +104,12 @@ public class Rygel.InteractiveResponse : Rygel.HTTPResponse {
             warning ("Failed to read contents from URI: %s: %s\n",
                      this.file.get_uri (),
                      err.message);
-            this.msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
+            this.end (false, Soup.KnownStatusCode.NOT_FOUND);
             return;
         }
 
         this.push_data (this.buffer, this.length);
-        this.end (false);
+        this.end (false, Soup.KnownStatusCode.NONE);
     }
 }
 
index 4345218..96d40be 100644 (file)
@@ -60,7 +60,7 @@ public class Rygel.StreamingResponse : Rygel.HTTPResponse {
         this.pipeline.set_state (State.PLAYING);
     }
 
-    public override void end (bool aborted) {
+    public override void end (bool aborted, uint status) {
         this.pipeline.set_state (State.NULL);
         // Flush the queue of buffers
         Buffer buffer = null;
@@ -72,7 +72,7 @@ public class Rygel.StreamingResponse : Rygel.HTTPResponse {
             this.msg.response_body.complete ();
         }
 
-        base.end (aborted);
+        base.end (aborted, status);
     }
 
     private void prepare_pipeline (string name,
@@ -124,7 +124,7 @@ public class Rygel.StreamingResponse : Rygel.HTTPResponse {
                 critical ("Failed to link %s to %s",
                           depay.name,
                           sink.name);
-                this.end (false);
+                this.end (false, Soup.KnownStatusCode.NONE);
                 return;
             }
 
@@ -137,7 +137,7 @@ public class Rygel.StreamingResponse : Rygel.HTTPResponse {
             critical ("Failed to link pad %s to %s",
                       src_pad.name,
                       sink_pad.name);
-            this.end (false);
+            this.end (false, Soup.KnownStatusCode.NONE);
             return;
         }
 
@@ -248,7 +248,7 @@ public class Rygel.StreamingResponse : Rygel.HTTPResponse {
         }
 
         if (!ret) {
-            this.end (false);
+            this.end (false, Soup.KnownStatusCode.NONE);
         }
 
         return ret;