[rygel] core: Refactor HTTRequest classes a bit
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Refactor HTTRequest classes a bit
- Date: Sun, 8 Aug 2010 23:19:26 +0000 (UTC)
commit e43a41a1eeb4fc2c0c9340c68825a273727ac50b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sat Aug 7 04:32:04 2010 +0300
core: Refactor HTTRequest classes a bit
The async code was a bit clumsy and therefore unreadable.
src/rygel/rygel-http-get.vala | 4 ----
src/rygel/rygel-http-post.vala | 3 ---
src/rygel/rygel-http-request.vala | 14 ++++++++------
3 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/src/rygel/rygel-http-get.vala b/src/rygel/rygel-http-get.vala
index bc3dfef..70d89a5 100644
--- a/src/rygel/rygel-http-get.vala
+++ b/src/rygel/rygel-http-get.vala
@@ -48,10 +48,6 @@ internal class Rygel.HTTPGet : HTTPRequest {
}
protected override async void handle () throws Error {
- this.server.pause_message (this.msg);
-
- yield base.handle ();
-
var header = this.msg.request_headers.get (
"getcontentFeatures.dlna.org");
diff --git a/src/rygel/rygel-http-post.vala b/src/rygel/rygel-http-post.vala
index 568f96c..71b67eb 100644
--- a/src/rygel/rygel-http-post.vala
+++ b/src/rygel/rygel-http-post.vala
@@ -44,9 +44,6 @@ internal class Rygel.HTTPPost : HTTPRequest {
this.msg.got_chunk.connect (this.on_got_chunk);
this.msg.got_body.connect (this.on_got_body);
- this.server.pause_message (this.msg);
- yield base.handle ();
-
this.file = yield this.item.get_writable (this.cancellable);
if (this.file == null) {
throw new HTTPRequestError.BAD_REQUEST (
diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala
index b0b0fff..3973be7 100644
--- a/src/rygel/rygel-http-request.vala
+++ b/src/rygel/rygel-http-request.vala
@@ -54,7 +54,14 @@ internal abstract class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
}
public async void run () {
+ this.server.pause_message (this.msg);
+
try {
+ this.uri = new HTTPItemURI.from_string (this.msg.uri.path,
+ this.http_server);
+
+ yield this.find_item ();
+
yield this.handle ();
} catch (Error error) {
this.handle_error (error);
@@ -63,12 +70,7 @@ internal abstract class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
}
}
- protected virtual async void handle () throws Error {
- this.uri = new HTTPItemURI.from_string (this.msg.uri.path,
- this.http_server);
-
- yield this.find_item ();
- }
+ protected abstract async void handle () throws Error;
protected virtual async void find_item () throws Error {
// Fetch the requested item
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]