From d48d03755de3de23e2b9ad0d412eef82cd707579 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Sun, 18 Jan 2009 19:27:54 +0000 Subject: [PATCH] HTTPResponse.end takes HTTP status code to put on the message. 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 | 8 ++++++-- src/rygel/rygel-interactive-response.vala | 10 +++++----- src/rygel/rygel-streaming-response.vala | 10 +++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/rygel/rygel-http-response.vala b/src/rygel/rygel-http-response.vala index 5641c9b..c971396 100644 --- a/src/rygel/rygel-http-response.vala +++ b/src/rygel/rygel-http-response.vala @@ -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 (); } } diff --git a/src/rygel/rygel-interactive-response.vala b/src/rygel/rygel-interactive-response.vala index 6dd69f8..8d78eb5 100644 --- a/src/rygel/rygel-interactive-response.vala +++ b/src/rygel/rygel-interactive-response.vala @@ -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); } } diff --git a/src/rygel/rygel-streaming-response.vala b/src/rygel/rygel-streaming-response.vala index 4345218..96d40be 100644 --- a/src/rygel/rygel-streaming-response.vala +++ b/src/rygel/rygel-streaming-response.vala @@ -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; -- 2.7.4