[rygel] core: Handle case of no ID during item URI parsing
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Handle case of no ID during item URI parsing
- Date: Wed, 17 Feb 2010 13:40:49 +0000 (UTC)
commit 4e1c82fbf74d72cb996aee88b28950a80626914c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Jan 29 16:28:31 2010 +0200
core: Handle case of no ID during item URI parsing
src/rygel/rygel-http-item-uri.vala | 7 ++++++-
src/rygel/rygel-http-request.vala | 10 +++++-----
2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/rygel/rygel-http-item-uri.vala b/src/rygel/rygel-http-item-uri.vala
index 4c2dfb2..9cc5a51 100644
--- a/src/rygel/rygel-http-item-uri.vala
+++ b/src/rygel/rygel-http-item-uri.vala
@@ -36,7 +36,8 @@ internal class Rygel.HTTPItemURI : Object {
this.http_server = http_server;
}
- public HTTPItemURI.from_string (string uri, string server_root = "") {
+ public HTTPItemURI.from_string (string uri, string server_root = "")
+ throws HTTPRequestError {
// do not decode the path here as it may contain encoded slashes
this.thumbnail_index = -1;
this.transcode_target = null;
@@ -69,6 +70,10 @@ internal class Rygel.HTTPItemURI : Object {
break;
}
}
+
+ if (this.item_id == null) {
+ throw new HTTPRequestError.NOT_FOUND ("Not Found");
+ }
}
public string to_string() {
diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala
index afe1dd9..ac2118c 100644
--- a/src/rygel/rygel-http-request.vala
+++ b/src/rygel/rygel-http-request.vala
@@ -61,11 +61,11 @@ internal abstract class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
}
protected virtual async void handle () {
- this.uri = new HTTPItemURI.from_string (this.msg.uri.path,
- this.http_server.path_root);
-
- if (this.uri.item_id == null) {
- this.handle_error (new HTTPRequestError.NOT_FOUND ("Not Found"));
+ try {
+ this.uri = new HTTPItemURI.from_string (this.msg.uri.path,
+ this.http_server.path_root);
+ } catch (Error error) {
+ this.handle_error (error);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]