Backout 69154d62012c and b0b07ef904ea (bug 672448) due to warnings-as-errors red.

This commit is contained in:
Ryan VanderMeulen 2012-08-29 22:22:16 -04:00
parent 236b63bcd6
commit ebd9d07ef7
4 changed files with 48 additions and 153 deletions

View File

@ -20,7 +20,7 @@
// 2) #include IPDL boilerplate, and then undef LOG so our LOG wins.
// 3) nsNetModule.cpp does its own crazy stuff with #including prlog.h
// multiple times; allow it to define ALLOW_LATE_NSHTTP_H_INCLUDE to bypass
// check.
// check.
#if defined(PR_LOG) && !defined(ALLOW_LATE_NSHTTP_H_INCLUDE)
#error "If nsHttp.h #included it must come before any IPDL-generated files or other files that #include prlog.h"
#endif
@ -181,7 +181,7 @@ struct nsHttp
}
// Declare all atoms
//
//
// The atom names and values are stored in nsHttpAtomList.h and are brought
// to you by the magic of C preprocessing. Add new atoms to nsHttpAtomList
// and all support logic will be auto-generated.
@ -203,8 +203,8 @@ PRTimeToSeconds(PRTime t_usec)
#define NowInSeconds() PRTimeToSeconds(PR_Now())
// Round q-value to 2 decimal places; return 2 most significant digits as uint.
#define QVAL_TO_UINT(q) ((unsigned int) ((q + 0.005) * 100.0))
// round q-value to one decimal place; return most significant digit as uint.
#define QVAL_TO_UINT(q) ((unsigned int) ((q + 0.05) * 10.0))
#define HTTP_LWS " \t"
#define HTTP_HEADER_VALUE_SEPS HTTP_LWS ","

View File

@ -234,7 +234,7 @@ nsHttpHandler::Init()
if (prefBranch) {
prefBranch->AddObserver(HTTP_PREF_PREFIX, this, true);
prefBranch->AddObserver(UA_PREF_PREFIX, this, true);
prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, true);
prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, true);
prefBranch->AddObserver(NETWORK_ENABLEIDN, this, true);
prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, true);
prefBranch->AddObserver(DONOTTRACK_HEADER_ENABLED, this, true);
@ -292,8 +292,8 @@ nsHttpHandler::Init()
// Bring alive the objects in the http-protocol-startup category
NS_CreateServicesFromCategory(NS_HTTP_STARTUP_CATEGORY,
static_cast<nsISupports*>(static_cast<void*>(this)),
NS_HTTP_STARTUP_TOPIC);
NS_HTTP_STARTUP_TOPIC);
mObserverService = mozilla::services::GetObserverService();
if (mObserverService) {
mObserverService->AddObserver(this, "profile-change-net-teardown", true);
@ -303,7 +303,7 @@ nsHttpHandler::Init()
mObserverService->AddObserver(this, "net:prune-dead-connections", true);
mObserverService->AddObserver(this, "net:failed-to-process-uri-content", true);
}
return NS_OK;
}
@ -363,10 +363,10 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpHeaderArray *request,
// transparent proxies) can result.
//
// However, we need to send something so that we can use keepalive
// with HTTP/1.0 servers/proxies. We use "Proxy-Connection:" when
// with HTTP/1.0 servers/proxies. We use "Proxy-Connection:" when
// we're talking to an http proxy, and "Connection:" otherwise.
// We no longer send the Keep-Alive request header.
NS_NAMED_LITERAL_CSTRING(close, "close");
NS_NAMED_LITERAL_CSTRING(keepAlive, "keep-alive");
@ -435,7 +435,7 @@ nsHttpHandler::GetCookieService()
return mCookieService;
}
nsresult
nsresult
nsHttpHandler::GetIOService(nsIIOService** result)
{
NS_ADDREF(*result = mIOService);
@ -452,7 +452,7 @@ nsHttpHandler::Get32BitsOfPseudoRandom()
// 15 or 31 bits are common amounts.
PR_STATIC_ASSERT(RAND_MAX >= 0xfff);
#if RAND_MAX < 0xffffU
return ((uint16_t) rand() << 20) |
(((uint16_t) rand() & 0xfff) << 8) |
@ -521,10 +521,10 @@ nsHttpHandler::BuildUserAgent()
// preallocate to worst-case size, which should always be better
// than if we didn't preallocate at all.
mUserAgent.SetCapacity(mLegacyAppName.Length() +
mLegacyAppVersion.Length() +
mUserAgent.SetCapacity(mLegacyAppName.Length() +
mLegacyAppVersion.Length() +
#ifndef UA_SPARE_PLATFORM
mPlatform.Length() +
mPlatform.Length() +
#endif
mOscpu.Length() +
mMisc.Length() +
@ -674,7 +674,7 @@ nsHttpHandler::InitUserAgentComponents()
}
#elif defined (XP_UNIX)
struct utsname name;
int ret = uname(&name);
if (ret >= 0) {
nsCAutoString buf;
@ -981,7 +981,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
if (NS_SUCCEEDED(rv))
SetAccept(accept);
}
if (PREF_CHANGED(HTTP_PREF("accept-encoding"))) {
nsXPIDLCString acceptEncodings;
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"),
@ -1034,7 +1034,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
mEnforceAssocReq = cVar;
}
// enable Persistent caching for HTTPS - bug#205921
// enable Persistent caching for HTTPS - bug#205921
if (PREF_CHANGED(BROWSER_PREF("disk_cache_ssl"))) {
cVar = false;
rv = prefs->GetBoolPref(BROWSER_PREF("disk_cache_ssl"), &cVar);
@ -1141,7 +1141,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
pls->ToString(getter_Copies(uval));
if (uval)
SetAcceptLanguages(NS_ConvertUTF16toUTF8(uval).get());
}
}
}
//
@ -1221,7 +1221,7 @@ PrepareAcceptLanguages(const char *i_AcceptLanguages, nsACString &o_AcceptLangua
if (!i_AcceptLanguages)
return NS_OK;
uint32_t n, count_n, size, wrote;
uint32_t n, size, wrote;
double q, dec;
char *p, *p2, *token, *q_Accept, *o_Accept;
const char *comma;
@ -1244,7 +1244,7 @@ PrepareAcceptLanguages(const char *i_AcceptLanguages, nsACString &o_AcceptLangua
*q_Accept = '\0';
q = 1.0;
dec = q / (double) n;
count_n = 0;
n = 0;
p2 = q_Accept;
for (token = nsCRT::strtok(o_Accept, ",", &p);
token != (char *) 0;
@ -1257,28 +1257,12 @@ PrepareAcceptLanguages(const char *i_AcceptLanguages, nsACString &o_AcceptLangua
*trim = '\0';
if (*token != '\0') {
comma = count_n++ != 0 ? "," : ""; // delimiter if not first item
comma = n++ != 0 ? "," : ""; // delimiter if not first item
uint32_t u = QVAL_TO_UINT(q);
// Only display q-value if less than 1.00.
if (u < 100) {
char *qval_str;
// With a small number of languages, one decimal place is enough to prevent duplicate q-values.
// Also, trailing zeroes do not add any information, so they can be removed.
if ((n < 10) || ((u % 10) == 0)) {
u = (u + 5) / 10;
qval_str = "%s%s;q=0.%u";
} else {
// Values below 10 require zero padding.
qval_str = "%s%s;q=0.%02u";
}
wrote = PR_snprintf(p2, available, qval_str, comma, token, u);
} else {
if (u < 10)
wrote = PR_snprintf(p2, available, "%s%s;q=0.%u", comma, token, u);
else
wrote = PR_snprintf(p2, available, "%s%s", comma, token);
}
q -= dec;
p2 += wrote;
available -= wrote;
@ -1294,7 +1278,7 @@ PrepareAcceptLanguages(const char *i_AcceptLanguages, nsACString &o_AcceptLangua
}
nsresult
nsHttpHandler::SetAcceptLanguages(const char *aAcceptLanguages)
nsHttpHandler::SetAcceptLanguages(const char *aAcceptLanguages)
{
nsCAutoString buf;
nsresult rv = PrepareAcceptLanguages(aAcceptLanguages, buf);
@ -1304,14 +1288,14 @@ nsHttpHandler::SetAcceptLanguages(const char *aAcceptLanguages)
}
nsresult
nsHttpHandler::SetAccept(const char *aAccept)
nsHttpHandler::SetAccept(const char *aAccept)
{
mAccept = aAccept;
return NS_OK;
}
nsresult
nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings)
nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings)
{
mAcceptEncodings = aAcceptEncodings;
return NS_OK;
@ -1389,10 +1373,10 @@ nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result)
return NewProxiedChannel(uri, nullptr, result);
}
NS_IMETHODIMP
NS_IMETHODIMP
nsHttpHandler::AllowPort(int32_t port, const char *scheme, bool *_retval)
{
// don't override anything.
// don't override anything.
*_retval = false;
return NS_OK;
}
@ -1410,7 +1394,7 @@ nsHttpHandler::NewProxiedChannel(nsIURI *uri,
LOG(("nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n",
givenProxyInfo));
nsCOMPtr<nsProxyInfo> proxyInfo;
if (givenProxyInfo) {
proxyInfo = do_QueryInterface(givenProxyInfo);
@ -1548,7 +1532,7 @@ nsHttpHandler::Observe(nsISupports *subject,
if (uri && mConnMgr)
mConnMgr->ReportFailedToProcess(uri);
}
return NS_OK;
}
@ -1563,7 +1547,7 @@ nsHttpHandler::SpeculativeConnect(nsIURI *aURI,
bool isStsHost = false;
if (!stss)
return NS_OK;
nsCOMPtr<nsIURI> clone;
if (NS_SUCCEEDED(stss->IsStsURI(aURI, &isStsHost)) && isStsHost) {
if (NS_SUCCEEDED(aURI->Clone(getter_AddRefs(clone)))) {
@ -1673,7 +1657,7 @@ nsHttpsHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)
NS_IMETHODIMP
nsHttpsHandler::AllowPort(int32_t aPort, const char *aScheme, bool *_retval)
{
// don't override anything.
// don't override anything.
*_retval = false;
return NS_OK;
}

View File

@ -1,88 +0,0 @@
//
// HTTP Accept-Language header test
//
const Cc = Components.classes;
const Ci = Components.interfaces;
var testpath = "/bug672448";
function run_test() {
let intlPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("intl.");
// Save old value of preference for later.
let oldPref = intlPrefs.getCharPref("accept_languages");
// Test different numbers of languages, to test different fractions.
let acceptLangTests = [
"qaa", // 1
"qaa,qab", // 2
"qaa,qab,qac,qad", // 4
"qaa,qab,qac,qad,qae,qaf,qag,qah", // 8
"qaa,qab,qac,qad,qae,qaf,qag,qah,qai,qaj", // 10
"qaa,qab,qac,qad,qae,qaf,qag,qah,qai,qaj,qak", // 11
"qaa,qab,qac,qad,qae,qaf,qag,qah,qai,qaj,qak,qal,qam,qan,qao,qap,qaq,qar,qas,qat,qau", // 21
oldPref, // Restore old value of preference (and test it).
];
let acceptLangTestsNum = acceptLangTests.length;
for (let i = 0; i < acceptLangTestsNum; i++) {
// Set preference to test value.
intlPrefs.setCharPref("accept_languages", acceptLangTests[i]);
// Test value.
test_accepted_languages();
}
}
function test_accepted_languages() {
let channel = setupChannel(testpath);
let AcceptLanguage = channel.getRequestHeader("Accept-Language");
let acceptedLanguages = AcceptLanguage.split(",");
let acceptedLanguagesLength = acceptedLanguages.length;
for (let i = 0; i < acceptedLanguagesLength; i++) {
let acceptedLanguage, qualityValue;
try {
// The q-value must conform to the definition in HTTP/1.1 Section 3.9.
[_, acceptedLanguage, qualityValue] = acceptedLanguages[i].trim().match(/^([a-z0-9_-]*?)(?:;q=(1(?:\.0{0,3})?|0(?:\.[0-9]{0,3})))?$/i);
} catch(e) {
do_throw("Invalid language tag or quality value: " + e);
}
if (i == 0) {
// The first language shouldn't have a quality value.
do_check_eq(qualityValue, undefined);
} else {
let decimalPlaces;
// When the number of languages is small, we keep the quality value to only one decimal place.
// Otherwise, it can be up to two decimal places.
if (acceptedLanguagesLength < 10) {
do_check_true(qualityValue.length == 3);
decimalPlaces = 1;
} else {
do_check_true(qualityValue.length >= 3);
do_check_true(qualityValue.length <= 4);
decimalPlaces = 2;
}
// All the other languages should have an evenly-spaced quality value.
do_check_eq(parseFloat(qualityValue).toFixed(decimalPlaces), (1.0 - ((1 / acceptedLanguagesLength) * i)).toFixed(decimalPlaces));
}
}
}
function setupChannel(path) {
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let chan = ios.newChannel("http://localhost:4444" + path, "", null);
chan.QueryInterface(Ci.nsIHttpChannel);
return chan;
}

View File

@ -42,7 +42,7 @@ skip-if = os == "android"
[test_bug455311.js]
[test_bug455598.js]
[test_bug468426.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_bug468594.js]
[test_bug470716.js]
@ -53,7 +53,7 @@ skip-if = os == "android"
[test_bug490095.js]
[test_bug504014.js]
[test_bug510359.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_bug515583.js]
[test_bug528292.js]
@ -71,16 +71,16 @@ skip-if = os == "android"
[test_bug652761.js]
[test_bug651100.js]
# Bug 675044: test fails consistently on Android
fail-if = os == "android"
fail-if = os == "android"
[test_bug654926.js]
# Bug 675049: test fails consistently on Android
fail-if = os == "android"
fail-if = os == "android"
[test_bug654926_doom_and_read.js]
# Bug 675049: test fails consistently on Android
fail-if = os == "android"
fail-if = os == "android"
[test_bug654926_test_seek.js]
# Bug 675049: test fails consistently on Android
fail-if = os == "android"
fail-if = os == "android"
[test_bug659569.js]
[test_bug660066.js]
[test_bug667907.js]
@ -103,28 +103,28 @@ fail-if = os == "android"
[test_extract_charset_from_content_type.js]
[test_force_sniffing.js]
[test_fallback_no-cache-entry_canceled.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_no-cache-entry_passing.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_redirect-to-different-origin_canceled.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_redirect-to-different-origin_passing.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_request-error_canceled.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_request-error_passing.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_response-error_canceled.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_fallback_response-error_passing.js]
# Bug 675039: test hangs consistently on Android
# Bug 675039: test hangs consistently on Android
skip-if = os == "android"
[test_file_partial_inputstream.js]
[test_file_protocol.js]
@ -132,7 +132,6 @@ skip-if = os == "android"
[test_gre_resources.js]
[test_gzipped_206.js]
[test_head.js]
[test_header_Accept-Language.js]
[test_headers.js]
[test_http_headers.js]
[test_httpcancel.js]