Bug 869725 - Changes to HTTP status line detection and parsing to allow AOL/Nullsoft ShoutCast headers (e.g. ICY 200 OK) [r=mcmanus]

This commit is contained in:
Chris Sperry 2013-05-16 12:22:06 -07:00
Родитель 1824d45b21
Коммит 6dffeb3c2b
2 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -578,6 +578,12 @@ nsHttpResponseHead::ParseVersion(const char *str)
// make sure we have HTTP at the beginning
if (PL_strncasecmp(str, "HTTP", 4) != 0) {
if (PL_strncasecmp(str, "ICY ", 4) == 0) {
// ShoutCast ICY is HTTP/1.0-like. Assume it is HTTP/1.0.
LOG(("Treating ICY as HTTP 1.0\n"));
mVersion = NS_HTTP_VERSION_1_0;
return;
}
LOG(("looks like a HTTP/0.9 response\n"));
mVersion = NS_HTTP_VERSION_0_9;
return;

Просмотреть файл

@ -977,6 +977,9 @@ nsHttpTransaction::LocateHttpStart(char *buf, uint32_t len,
static const uint32_t HTTPHeaderLen = sizeof(HTTPHeader) - 1;
static const char HTTP2Header[] = "HTTP/2.0";
static const uint32_t HTTP2HeaderLen = sizeof(HTTP2Header) - 1;
// ShoutCast ICY is treated as HTTP/1.0
static const char ICYHeader[] = "ICY ";
static const uint32_t ICYHeaderLen = sizeof(ICYHeader) - 1;
if (aAllowPartialMatch && (len < HTTPHeaderLen))
return (PL_strncasecmp(buf, HTTPHeader, len) == 0) ? buf : nullptr;
@ -1026,6 +1029,16 @@ nsHttpTransaction::LocateHttpStart(char *buf, uint32_t len,
return buf;
}
// Treat ICY (AOL/Nullsoft ShoutCast) non-standard header in same fashion
// as HTTP/2.0 is treated above. This will allow "ICY " to be interpretted
// as HTTP/1.0 in nsHttpResponseHead::ParseVersion
if (firstByte && !mInvalidResponseBytesRead && len >= ICYHeaderLen &&
(PL_strncasecmp(buf, ICYHeader, ICYHeaderLen) == 0)) {
LOG(("nsHttpTransaction:: Identified ICY treating as HTTP/1.0\n"));
return buf;
}
if (!nsCRT::IsAsciiSpace(*buf))
firstByte = false;
buf++;