/* -*- 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/. */
#ifdef Status /* Xlib headers insist on this for some reason... Nuke it because
it'll override our member name */ typedef Status __StatusTmp; # undef Status typedef __StatusTmp Status; #endif
class nsIHttpHeaderVisitor;
// 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 {
//----------------------------------------------------------------------------- // nsHttpResponseHead represents the status line and headers from an HTTP // response. //-----------------------------------------------------------------------------
class nsHttpResponseHead { public:
nsHttpResponseHead() = default;
HttpVersion Version() const;
uint16_t Status() const; void StatusText(nsACString& aStatusText);
int64_t ContentLength(); void ContentType(nsACString& aContentType) const; void ContentCharset(nsACString& aContentCharset); boolPublic(); boolPrivate(); bool NoStore(); bool NoCache(); bool Immutable(); /** * Full length of the entity. For byte-range requests, this may be larger * than ContentLength(), which will only represent the requested part of the * entity.
*/
int64_t TotalEntitySize();
// write out the response status line and headers as a single text block, // optionally pruning out transient headers (ie. headers that only make // sense the first time the response is handled). // Both functions append to the string supplied string. void Flatten(nsACString&, bool pruneTransients); void FlattenNetworkOriginalHeaders(nsACString& buf);
// The next 2 functions parse flattened response head and original net // headers. They are used when we are reading an entry from the cache. // // To keep proper order of the original headers we MUST call // ParseCachedOriginalHeaders FIRST and then ParseCachedHead. // // block must be null terminated.
[[nodiscard]] nsresult ParseCachedHead(constchar* block);
[[nodiscard]] nsresult ParseCachedOriginalHeaders(char* block);
// parse the status line.
nsresult ParseStatusLine(const nsACString& line);
// parse a header line.
[[nodiscard]] nsresult ParseHeaderLine(const nsACString& line);
// return true if the response contains a valid Cache-control: // stale-while-revalidate and |now| is less than or equal |expiration + // stale-while-revalidate|. Otherwise false. bool StaleWhileRevalidate(uint32_t now, uint32_t expiration);
// returns true if the server appears to support byte range requests. bool IsResumable();
// returns true if the Expires header has a value in the past relative to the // value of the Date header. bool ExpiresInPast();
// Using this function it is possible to itereate through all headers // automatically under one lock.
[[nodiscard]] nsresult VisitHeaders(nsIHttpHeaderVisitor* visitor,
nsHttpHeaderArray::VisitorFilter filter);
[[nodiscard]] nsresult GetOriginalHeader(const nsHttpAtom& aHeader,
nsIHttpHeaderVisitor* aVisitor);
// We are using RecursiveMutex instead of a Mutex because VisitHeader // function calls nsIHttpHeaderVisitor::VisitHeader while under lock. mutable RecursiveMutex mRecursiveMutex{"nsHttpResponseHead.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.