/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et tw=80 : */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// HttpLog.h should generally be included first #include"HttpLog.h"
void Http2Stream::CloseStream(nsresult reason) { // In case we are connected to a push, make sure the push knows we are closed, // so it doesn't try to give us any more DATA that comes on it after our // close.
ClearPushSource();
// If a push stream is attached to the transaction via onPush, match only // with that one. This occurs when a push was made with in conjunction with // a nsIHttpPushListener
nsHttpTransaction* trans = mTransaction->QueryHttpTransaction(); if (trans && (pushedStreamWrapper = trans->TakePushedStream()) &&
(pushedStream = pushedStreamWrapper->GetStream())) {
RefPtr<Http2Session> pushSession = pushedStream->Session(); if (pushSession == session) {
LOG3(
("Pushed Stream match based on OnPush correlation %p", pushedStream));
} else {
LOG3(("Pushed Stream match failed due to stream mismatch %p %" PRId64 " %" PRId64 "\n",
pushedStream, pushSession->Serial(), session->Serial()));
pushedStream->OnPushFailed();
pushedStream = nullptr;
}
}
// we remove the pushedstream from the push cache so that // it will not be used for another GET. This does not destroy the // stream itself - that is done when the transactionhash is done with it. if (cache && !pushedStream) {
pushedStream = cache->RemovePushedStreamHttp2(hashkey);
}
if (pushedStream) {
LOG3(("Pushed Stream Match located %p id=0x%X key=%s\n", pushedStream,
pushedStream->StreamID(), hashkey.get()));
pushedStream->SetConsumerStream(this);
mPushSource = pushedStream;
SetSentFin(true);
AdjustPushedPriority();
// There is probably pushed data buffered so trigger a read manually // as we can't rely on future network events to do it
session->ConnectPushedStream(this);
mOpenGenerated = 1;
// if the "mother stream" had TRR, this one is a TRR stream too!
RefPtr<nsHttpConnectionInfo> ci(Transaction()->ConnectionInfo()); if (ci && ci->GetIsTrrServiceChannel()) {
session->IncrementTrrCounter();
}
}
return NS_OK;
}
uint32_t Http2Stream::GetWireStreamId() { // >0 even numbered IDs are pushed streams. // odd numbered IDs are pulled streams. // 0 is the sink for a pushed stream. if (!mStreamID) {
MOZ_ASSERT(mPushSource); if (!mPushSource) { return 0;
}
MOZ_ASSERT(mPushSource->StreamID());
MOZ_ASSERT(!(mPushSource->StreamID() & 1)); // is a push stream
// If the pushed stream has recvd a FIN, there is no reason to update // the window if (mPushSource->RecvdFin() || mPushSource->RecvdReset() ||
(mPushSource->HTTPState() == RESERVED_BY_REMOTE)) { return 0;
} return mPushSource->StreamID();
}
if (mState == RESERVED_BY_REMOTE) { // h2-14 prevents sending a window update in this state return 0;
} return mStreamID;
}
void Http2Stream::AdjustPushedPriority() { // >0 even numbered IDs are pushed streams. odd numbered IDs are pulled // streams. 0 is the sink for a pushed stream.
// This is really a headers frame, but open is pretty clear from a workflow pov
nsresult Http2Stream::GenerateHeaders(nsCString& aCompressedData,
uint8_t& firstFrameFlags) {
nsHttpRequestHead* head = mTransaction->RequestHead();
nsAutoCString requestURI;
head->RequestURI(requestURI);
RefPtr<Http2Session> session = Session();
LOG3(("Http2Stream %p Stream ID 0x%X [session=%p] for URI %s\n", this,
mStreamID, session.get(), requestURI.get()));
// Determine whether to put the fin bit on the header frame or whether // to wait for a data packet to put it on.
if (head->IsGet() || head->IsHead()) { // for GET and HEAD place the fin bit right on the // header packet
firstFrameFlags |= Http2Session::kFlag_END_STREAM;
} elseif (head->IsPost() || head->IsPut() || head->IsConnect()) { // place fin in a data frame even for 0 length messages for iterop
} elseif (!mRequestBodyLenRemaining) { // for other HTTP extension methods, rely on the content-length // to determine whether or not to put fin on headers
firstFrameFlags |= Http2Session::kFlag_END_STREAM;
}
// The size of the input headers is approximate
uint32_t ratio =
aCompressedData.Length() * 100 /
(11 + requestURI.Length() + mFlatHttpRequestHeaders.Length());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.