Bug 1644377 - Use only the first Http3 versionfrom AltSvc and add X_Firefox_Http3 header. r=michal,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D79070
This commit is contained in:
Dragana Damjanovic 2020-06-10 10:24:49 +00:00
parent fb111b765c
commit a886b3e138
4 changed files with 19 additions and 0 deletions

View File

@ -82,6 +82,9 @@ void AltSvcMapping::ProcessHeader(
ParsedHeaderValueListList parsedAltSvc(buf);
int32_t numEntriesInHeader = parsedAltSvc.mValues.Length();
// Only use one http3 version.
bool http3Found = false;
for (uint32_t index = 0; index < parsedAltSvc.mValues.Length(); ++index) {
uint32_t maxage = 86400; // default
nsAutoCString hostname;
@ -146,6 +149,11 @@ void AltSvcMapping::ProcessHeader(
nsUnescape(npnToken.BeginWriting());
npnToken.SetLength(strlen(npnToken.BeginReading()));
if (http3Found && isHttp3) {
LOG(("Alt Svc ignore multiple Http3 options (%s)", npnToken.get()));
continue;
}
uint32_t spdyIndex;
SpdyInformation* spdyInfo = gHttpHandler->SpdyInfo();
if (!(NS_SUCCEEDED(spdyInfo->GetNPNIndex(npnToken, &spdyIndex)) &&
@ -155,6 +163,8 @@ void AltSvcMapping::ProcessHeader(
continue;
}
http3Found = true;
RefPtr<AltSvcMapping> mapping = new AltSvcMapping(
gHttpHandler->AltServiceCache()->GetStoragePtr(),
gHttpHandler->AltServiceCache()->StorageEpoch(), originScheme,

View File

@ -98,6 +98,8 @@ class Http3Session final : public nsAHttpTransaction,
nsresult ProcessOutputAndEvents();
const nsCString& GetAlpnToken() { return mAlpnToken; }
private:
~Http3Session();

View File

@ -298,6 +298,12 @@ nsresult HttpConnectionUDP::OnHeadersAvailable(nsAHttpTransaction* trans,
NS_ENSURE_ARG_POINTER(trans);
MOZ_ASSERT(responseHead, "No response head?");
if (mHttp3Session) {
DebugOnly<nsresult> rv = responseHead->SetHeader(
nsHttp::X_Firefox_Http3, mHttp3Session->GetAlpnToken());
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
// deal with 408 Server Timeouts
uint16_t responseStatus = responseHead->Status();
static const PRIntervalTime k1000ms = PR_MillisecondsToInterval(1000);

View File

@ -99,5 +99,6 @@ HTTP_ATOM(X_Firefox_Spdy, "X-Firefox-Spdy")
HTTP_ATOM(X_Firefox_Spdy_Proxy, "X-Firefox-Spdy-Proxy")
HTTP_ATOM(X_Firefox_Early_Data, "X-Firefox-Early-Data")
HTTP_ATOM(X_Firefox_TCP_Fast_Open, "X-Firefox-TCP-Fast-Open")
HTTP_ATOM(X_Firefox_Http3, "X-Firefox-Http3")
// methods are case sensitive and do not use atom table