Bug 1082039 - nsIHttpChannelInternal.allowSpdy is racy r=hurley

This commit is contained in:
Patrick McManus 2014-10-13 12:40:45 -04:00
Родитель bc0538b160
Коммит 64cd00171f
4 изменённых файлов: 23 добавлений и 3 удалений

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

@ -316,6 +316,7 @@ nsHttpChannel::Connect()
// Finalize ConnectionInfo flags before SpeculativeConnect
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
mConnectionInfo->SetPrivate(mPrivateBrowsing);
mConnectionInfo->SetNoSpdy(mCaps & NS_HTTP_DISALLOW_SPDY);
// Consider opening a TCP connection right away
RetrieveSSLOptions();
@ -1246,7 +1247,7 @@ nsHttpChannel::ProcessAltService()
// protocol-id = token ; percent-encoded ALPN protocol identifier
// alt-authority = quoted-string ; containing [ uri-host ] ":" port
if (!gHttpHandler->AllowAltSvc()) {
if (!gHttpHandler->AllowAltSvc() || (mCaps & NS_HTTP_DISALLOW_SPDY)) {
return;
}

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

@ -112,8 +112,9 @@ nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port)
// byte 2 is A/. A is for an anonymous channel (no cookies, etc..)
// byte 3 is P/. P is for a private browising channel
// byte 4 is R/. R is for 'relaxed' unauthed TLS for http:// uris
// byte 5 is X/. X is for disallow_spdy flag
mHashKey.AssignLiteral(".....");
mHashKey.AssignLiteral("......");
mHashKey.Append(keyHost);
mHashKey.Append(':');
mHashKey.AppendInt(keyPort);
@ -185,6 +186,7 @@ nsHttpConnectionInfo::Clone() const
clone->SetAnonymous(GetAnonymous());
clone->SetPrivate(GetPrivate());
clone->SetRelaxed(GetRelaxed());
clone->SetNoSpdy(GetNoSpdy());
MOZ_ASSERT(clone->Equals(this));
return clone;
@ -205,6 +207,7 @@ nsHttpConnectionInfo::CloneAsDirectRoute(nsHttpConnectionInfo **outCI)
clone->SetAnonymous(GetAnonymous());
clone->SetPrivate(GetPrivate());
clone->SetRelaxed(GetRelaxed());
clone->SetNoSpdy(GetNoSpdy());
clone.forget(outCI);
}

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

@ -96,6 +96,10 @@ public:
{ mHashKey.SetCharAt(relaxed ? 'R' : '.', 4); }
bool GetRelaxed() const { return mHashKey.CharAt(4) == 'R'; }
void SetNoSpdy(bool aNoSpdy)
{ mHashKey.SetCharAt(aNoSpdy ? 'X' : '.', 5); }
bool GetNoSpdy() const { return mHashKey.CharAt(5) == 'X'; }
const nsCString &GetHost() { return mHost; }
const nsCString &GetNPNToken() { return mNPNToken; }

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

@ -43,6 +43,7 @@ Http2CheckListener.prototype = {
onStartRequestFired: false,
onDataAvailableFired: false,
isHttp2Connection: false,
shouldBeHttp2 : true,
onStartRequest: function testOnStartRequest(request, ctx) {
this.onStartRequestFired = true;
@ -66,7 +67,7 @@ Http2CheckListener.prototype = {
onStopRequest: function testOnStopRequest(request, ctx, status) {
do_check_true(this.onStartRequestFired);
do_check_true(this.onDataAvailableFired);
do_check_true(this.isHttp2Connection);
do_check_true(this.isHttp2Connection == this.shouldBeHttp2);
run_next_test();
do_test_finished();
@ -202,6 +203,16 @@ function test_http2_basic() {
chan.asyncOpen(listener, null);
}
// make sure we don't use h2 when disallowed
function test_http2_nospdy() {
var chan = makeChan("https://localhost:6944/");
var listener = new Http2CheckListener();
var internalChannel = chan.QueryInterface(Ci.nsIHttpChannelInternal);
internalChannel.allowSpdy = false;
listener.shouldBeHttp2 = false;
chan.asyncOpen(listener, null);
}
// Support for making sure XHR works over SPDY
function checkXhr(xhr) {
if (xhr.readyState != 4) {
@ -389,6 +400,7 @@ function test_http2_altsvc() {
// a stalled stream when a SETTINGS frame arrives
var tests = [ test_http2_post_big
, test_http2_basic
, test_http2_nospdy
, test_http2_push1
, test_http2_push2
, test_http2_push3