[rygel] core: Delay response on ImportResource



commit c76c66e8342024c3264ae59597b9848ab1b8d965
Author: Jens Georg <mail jensge org>
Date:   Wed Jun 1 13:09:17 2011 +0200

    core: Delay response on ImportResource
    
    Delay it until we get the headers from the actual import. UPnP tests
    require that if the server has an error, the action needs to return with
    error 715.
    
    Partially fixes UPnP CTT AV-CD:1-9.1.
    
    Co-author: Zeeshan Ali (Khattak) <zeeshanak gnome org>

 src/rygel/rygel-import-resource.vala |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/rygel/rygel-import-resource.vala b/src/rygel/rygel-import-resource.vala
index 4ab7a20..69cbdc6 100644
--- a/src/rygel/rygel-import-resource.vala
+++ b/src/rygel/rygel-import-resource.vala
@@ -135,9 +135,6 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
             return;
         }
 
-        // We can already return the action now
-        this.action.return ();
-
         var queue = ItemRemovalQueue.get_default ();
         queue.dequeue (this.item);
 
@@ -195,6 +192,24 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
 
     private void got_headers_cb (Message message) {
         this.bytes_total = message.response_headers.get_content_length ();
+
+        if (message.status_code >= 200 && message.status_code <= 299) {
+            this.action.return ();
+        } else {
+            this.status = TransferStatus.ERROR;
+            try {
+                this.output_stream.close (this.cancellable);
+                var file = File.new_for_uri (this.item.uris[0]);
+                file.delete (this.cancellable);
+            } catch (Error error) {};
+
+            var phrase = status_get_phrase (message.status_code);
+            if (message.status_code == 404) {
+                this.action.return_error (714, phrase);
+            } else {
+                this.action.return_error (715, phrase);
+            }
+        }
     }
 
     private void got_chunk_cb (Message message, Buffer buffer) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]