libsoup r1046 - in trunk: . libsoup tests
- From: danw svn gnome org
- To: svn-commits-list gnome org
- Subject: libsoup r1046 - in trunk: . libsoup tests
- Date: Wed, 16 Jan 2008 22:00:32 +0000 (GMT)
Author: danw
Date: Wed Jan 16 22:00:32 2008
New Revision: 1046
URL: http://svn.gnome.org/viewvc/libsoup?rev=1046&view=rev
Log:
* 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
Modified:
trunk/ChangeLog
trunk/libsoup/soup-headers.c
trunk/tests/header-parsing.c
Modified: trunk/libsoup/soup-headers.c
==============================================================================
--- trunk/libsoup/soup-headers.c (original)
+++ trunk/libsoup/soup-headers.c Wed Jan 16 22:00:32 2008
@@ -229,19 +229,23 @@
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')
Modified: trunk/tests/header-parsing.c
==============================================================================
--- trunk/tests/header-parsing.c (original)
+++ trunk/tests/header-parsing.c Wed Jan 16 22:00:32 2008
@@ -443,6 +443,14 @@
}
},
+ { "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 ***/
/*************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]