[libsoup/gnome-3-26] soup-headers: accept any 3 digit number as message status code



commit c60d7a851d3e3ac084bd5010656990c6a6a71c6b
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Jan 3 08:55:53 2018 +0100

    soup-headers: accept any 3 digit number as message status code
    
    The HTTP RFC says that status code is extensible, but the category must
    be known by the client. However, popular websites like linkedin use
    invalid status codes such as 999, and all the major browsers handle that
    correctly. There are also WPT tests checking status codes greater than
    599 in XMLHTTPRequests. So, let's parse the status code, only failing if
    it's not a 3 digit number and letting the user handle any other
    particular case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792124

 libsoup/soup-headers.c |    2 +-
 libsoup/soup-message.c |    2 +-
 tests/header-parsing.c |   12 ++++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index 1c8900e..271d2a6 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -323,7 +323,7 @@ soup_headers_parse_status_line (const char       *status_line,
        if (code_end != code_start + 3)
                return FALSE;
        code = atoi (code_start);
-       if (code < 100 || code > 599)
+       if (code < 100 || code > 999)
                return FALSE;
        if (status_code)
                *status_code = code;
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 6287ac1..e4d7847 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -766,7 +766,7 @@ soup_message_class_init (SoupMessageClass *message_class)
                g_param_spec_uint (SOUP_MESSAGE_STATUS_CODE,
                                   "Status code",
                                   "The HTTP response status code",
-                                  0, 599, 0,
+                                  0, 999, 0,
                                   G_PARAM_READWRITE));
        /**
         * SOUP_MESSAGE_REASON_PHRASE:
diff --git a/tests/header-parsing.c b/tests/header-parsing.c
index c896879..9cf06ce 100644
--- a/tests/header-parsing.c
+++ b/tests/header-parsing.c
@@ -517,6 +517,14 @@ static struct ResponseTest {
          }
        },
 
+       { "Response w/ unknown status code", NULL,
+         "HTTP/1.1 999 Request denied\r\nFoo: bar\r\n", -1,
+         SOUP_HTTP_1_1, 999, "Request denied",
+         { { "Foo", "bar" },
+           { NULL }
+         }
+       },
+
        { "Connection header on HTTP/1.0 message", NULL,
          "HTTP/1.0 200 ok\r\nFoo: bar\r\nConnection: Bar\r\nBar: quux\r\n", -1,
          SOUP_HTTP_1_0, SOUP_STATUS_OK, "ok",
@@ -704,8 +712,8 @@ static struct ResponseTest {
          { { NULL } }
        },
 
-       { "Status code > 599", NULL,
-         "HTTP/1.1 600 OK\r\nFoo: bar\r\n", -1,
+       { "Status code > 999", NULL,
+         "HTTP/1.1 1000 OK\r\nFoo: bar\r\n", -1,
          -1, 0, NULL,
          { { NULL } }
        },


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