[rygel] server: More precise error reporting



commit 8560b543d9348b62a9076154a456b10ce0819bd3
Author: Jens Georg <mail jensge org>
Date:   Sun Feb 8 19:00:03 2015 +0100

    server: More precise error reporting
    
    Split of error reporting about invalid getContentFeatures.dlna.org
    header and wrong request type (not HEAD or GET).
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/librygel-server/rygel-http-get.vala |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/librygel-server/rygel-http-get.vala b/src/librygel-server/rygel-http-get.vala
index a4bf8db..34dc199 100644
--- a/src/librygel-server/rygel-http-get.vala
+++ b/src/librygel-server/rygel-http-get.vala
@@ -2,11 +2,14 @@
  * Copyright (C) 2008-2010 Nokia Corporation.
  * Copyright (C) 2006, 2007, 2008 OpenedHand Ltd.
  * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2013 Cable Television Laboratories, Inc.
  *
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  *                               <zeeshan ali nokia com>
  *         Jorn Baayen <jorn baayen gmail com>
  *         Jens Georg <jensg openismus com>
+ *         Craig Pratt <craig ecaspia com>
+ *         Parthiban Balasubramanian <P Balasubramanian-contractor cablelabs com>
  *
  * This file is part of Rygel.
  *
@@ -50,13 +53,19 @@ internal class Rygel.HTTPGet : HTTPRequest {
     }
 
     protected override async void handle () throws Error {
-        var header = this.msg.request_headers.get_one
-                                        ("getcontentFeatures.dlna.org");
-
         /* We only entertain 'HEAD' and 'GET' requests */
-        if ((this.msg.method != "HEAD" && this.msg.method != "GET") ||
-            (header != null && header != "1")) {
-            throw new HTTPRequestError.BAD_REQUEST (_("Invalid Request"));
+        if (!(this.msg.method == "HEAD" || this.msg.method == "GET")) {
+            throw new HTTPRequestError.BAD_REQUEST
+                          (_("Invalid Request (only GET and HEAD supported)"));
+        }
+
+        { /* Check for proper content feature request */
+            var cf_header = "getcontentFeatures.dlna.org";
+            var cf_val = this.msg.request_headers.get_one (cf_header);
+
+            if (cf_val != null && cf_val != "1") {
+                throw new HTTPRequestError.BAD_REQUEST (_(cf_header + " must be 1"));
+            }
         }
 
         if (uri.resource_name != null) {


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