diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index c430ad085..183684b68 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -181,7 +181,8 @@ HttpBaseChannel::Init(nsIURI *aURI, rv = mRequestHead.SetHeader(nsHttp::Host, hostLine); if (NS_FAILED(rv)) return rv; - rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead.Headers(), isHTTPS); + rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead.Headers(), isHTTPS, +hostLine); if (NS_FAILED(rv)) return rv; nsAutoCString type; diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 7c50cfe94..d118a488d 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -422,14 +422,28 @@ nsHttpHandler::InitConnectionMgr() } nsresult -nsHttpHandler::AddStandardRequestHeaders(nsHttpHeaderArray *request, bool isSecure) +nsHttpHandler::AddStandardRequestHeaders(nsHttpHeaderArray *request, + bool isSecure, + const nsACString &hostLine) { nsresult rv; - // Add the "User-Agent" header - rv = request->SetHeader(nsHttp::User_Agent, UserAgent(), - false, nsHttpHeaderArray::eVarietyDefault); - if (NS_FAILED(rv)) return rv; + // Add the "User-Agent" header (unless we have blacklisted this site and + // we aren't using a custom user agent; see TenFourFox issue 422). + if (mUserAgentOverride || ( + !hostLine.EqualsLiteral("i.imgur.com") && + !hostLine.EqualsLiteral("imgur.com") && + 1)) { + rv = request->SetHeader(nsHttp::User_Agent, UserAgent(), + false, nsHttpHeaderArray::eVarietyDefault); + if (NS_FAILED(rv)) return rv; + } +#if DEBUG + else { + fprintf(stderr, "User agent header suppressed for host: %s\n", + PromiseFlatCString(hostLine).get()); + } +#endif // MIME based content negotiation lives! // Add the "Accept" header. Note, this is set as an override because the diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 6bd27389e..0e825700c 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -67,7 +67,8 @@ public: nsHttpHandler(); nsresult Init(); - nsresult AddStandardRequestHeaders(nsHttpHeaderArray *, bool isSecure); + nsresult AddStandardRequestHeaders(nsHttpHeaderArray *, bool isSecure, + const nsACString &hostLine); nsresult AddConnectionHeader(nsHttpHeaderArray *, uint32_t capabilities); bool IsAcceptableEncoding(const char *encoding, bool isSecure);