/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */
// This needs to be forward declared here so we can include only this header // without also including PHttpChannelParams.h namespace IPC { template <typename> struct ParamTraits;
} // namespace IPC
namespace mozilla { namespace net {
//----------------------------------------------------------------------------- // nsHttpRequestHead represents the request line and headers from an HTTP // request. //-----------------------------------------------------------------------------
// The following function is only used in HttpChannelParent to avoid // copying headers. If you use it be careful to do it only under // nsHttpRequestHead lock!!! const nsHttpHeaderArray& Headers() const MOZ_REQUIRES(mRecursiveMutex); void Enter() const MOZ_CAPABILITY_ACQUIRE(mRecursiveMutex) {
mRecursiveMutex.Lock();
} voidExit() const MOZ_CAPABILITY_RELEASE(mRecursiveMutex) {
mRecursiveMutex.Unlock();
}
// Using this function it is possible to itereate through all headers // automatically under one lock.
[[nodiscard]] nsresult VisitHeaders(
nsIHttpHeaderVisitor* visitor,
nsHttpHeaderArray::VisitorFilter filter = nsHttpHeaderArray::eFilterAll); void Method(nsACString& aMethod);
HttpVersion Version(); void RequestURI(nsACString& RequestURI); void Path(nsACString& aPath); void SetHTTPS(bool val); bool IsHTTPS();
bool HasHeaderValue(const nsHttpAtom& h, constchar* v); // This function returns true if header is set even if it is an empty // header. bool HasHeader(const nsHttpAtom& h); void Flatten(nsACString&, bool pruneProxyHeaders = false);
private: // All members must be copy-constructable and assignable
nsHttpHeaderArray mHeaders MOZ_GUARDED_BY(mRecursiveMutex);
nsCString mMethod MOZ_GUARDED_BY(mRecursiveMutex){"GET"_ns};
HttpVersion mVersion MOZ_GUARDED_BY(mRecursiveMutex){HttpVersion::v1_1};
// mRequestURI and mPath are strings instead of an nsIURI // because this is used off the main thread // TODO: nsIURI is thread-safe now, should be fixable.
nsCString mRequestURI MOZ_GUARDED_BY(mRecursiveMutex);
nsCString mPath MOZ_GUARDED_BY(mRecursiveMutex);
// We are using RecursiveMutex instead of a Mutex because VisitHeader // function calls nsIHttpHeaderVisitor::VisitHeader while under lock. mutable RecursiveMutex mRecursiveMutex MOZ_UNANNOTATED{ "nsHttpRequestHead.mRecursiveMutex"};
// During VisitHeader we sould not allow call to SetHeader. bool mInVisitHeaders MOZ_GUARDED_BY(mRecursiveMutex){false};
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.