Skip to content

Commit

Permalink
Bug 869725 - Changes to HTTP status line detection and parsing to all…
Browse files Browse the repository at this point in the history
…ow AOL/Nullsoft ShoutCast headers (e.g. ICY 200 OK) [r=mcmanus]
  • Loading branch information
Chris Sperry committed May 16, 2013
1 parent 3ad6f15 commit 8d49ac9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netwerk/protocol/http/nsHttpResponseHead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions netwerk/protocol/http/nsHttpTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 8d49ac9

Please sign in to comment.