2008-01-16 Dan Winship <danw@gnome.org>
+ * libsoup/soup-headers.c (soup_headers_parse_status_line): Deal
+ with Shoutcast servers, which return "ICY 200 OK", but are
+ otherwise straight HTTP/1.0. #502325, Wouter Cloetens.
+
+ * tests/header-parsing.c (resptests): add a test for it
+
+2008-01-16 Dan Winship <danw@gnome.org>
+
* libsoup/soup-auth-manager.c (authorize_handler, etc): Allow the
session authenticate signal to be handled asynchronously, by
pausing the message and then authenticating the auth later.
const char *code_start, *code_end, *phrase_start, *phrase_end;
char *p;
- if (strncmp (status_line, "HTTP/", 5) != 0 ||
- !g_ascii_isdigit (status_line[5]))
- return FALSE;
- major_version = strtoul (status_line + 5, &p, 10);
- if (*p != '.' || !g_ascii_isdigit (p[1]))
- return FALSE;
- minor_version = strtoul (p + 1, &p, 10);
- if (major_version != 1)
- return FALSE;
- if (minor_version < 0 || minor_version > 1)
- return FALSE;
- if (ver)
- *ver = (minor_version == 0) ? SOUP_HTTP_1_0 : SOUP_HTTP_1_1;
+ if (strncmp (status_line, "HTTP/", 5) == 0 &&
+ g_ascii_isdigit (status_line[5])) {
+ major_version = strtoul (status_line + 5, &p, 10);
+ if (*p != '.' || !g_ascii_isdigit (p[1]))
+ return FALSE;
+ minor_version = strtoul (p + 1, &p, 10);
+ if (major_version != 1)
+ return FALSE;
+ if (minor_version < 0 || minor_version > 1)
+ return FALSE;
+ if (ver)
+ *ver = (minor_version == 0) ? SOUP_HTTP_1_0 : SOUP_HTTP_1_1;
+ } else if (!strncmp (status_line, "ICY", 3)) {
+ /* Shoutcast not-quite-HTTP format */
+ *ver = SOUP_HTTP_1_0;
+ p = (char *)status_line + 3;
+ }
code_start = p;
while (*code_start == ' ' || *code_start == '\t')
}
},
+ { "Shoutcast server not-quite-HTTP",
+ "ICY 200 OK\r\nFoo: bar\r\n", -1,
+ SOUP_HTTP_1_0, SOUP_STATUS_OK, "OK",
+ { { "Foo", "bar" },
+ { NULL }
+ }
+ },
+
/*************************/
/*** INVALID RESPONSES ***/
/*************************/