[gupnp] Return 400 to NOTIFYs without NT or NTS header



commit 4aabe93dcbbdfa4da6123117216d5a8a95ce1de5
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date:   Wed Apr 17 14:27:40 2013 +0300

    Return 400 to NOTIFYs without NT or NTS header
    
    We used to return 412 if the "NT" or "NTS" header field was missing.
    Spec says we should return 400.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698192

 libgupnp/gupnp-service-proxy.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index 0b17d1b..972c48a 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -1818,7 +1818,7 @@ server_handler (SoupServer        *soup_server,
                 gpointer           user_data)
 {
         GUPnPServiceProxy *proxy;
-        const char *hdr;
+        const char *hdr, *nt, *nts;
         int seq;
         xmlDoc *doc;
         xmlNode *node;
@@ -1833,17 +1833,18 @@ server_handler (SoupServer        *soup_server,
                 return;
         }
 
-        hdr = soup_message_headers_get_one (msg->request_headers, "NT");
-        if (hdr == NULL || strcmp (hdr, "upnp:event") != 0) {
-                /* Proper NT header lacking */
-                soup_message_set_status (msg, SOUP_STATUS_PRECONDITION_FAILED);
+        nt = soup_message_headers_get_one (msg->request_headers, "NT");
+        nts = soup_message_headers_get_one (msg->request_headers, "NTS");
+        if (nt == NULL || nts == NULL) {
+                /* Required header is missing */
+                soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
 
                 return;
         }
 
-        hdr = soup_message_headers_get_one (msg->request_headers, "NTS");
-        if (hdr == NULL || strcmp (hdr, "upnp:propchange") != 0) {
-                /* Proper NTS header lacking */
+        if (strcmp (nt, "upnp:event") != 0 ||
+            strcmp (nts, "upnp:propchange") != 0) {
+                /* Unexpected header content */
                 soup_message_set_status (msg, SOUP_STATUS_PRECONDITION_FAILED);
 
                 return;


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