#include "third_party/blink/renderer/platform/network/http_parsers.h"
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include "base/containers/flat_map.h"
#include "base/feature_list.h"
#include "net/http/http_content_disposition.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/content_security_policy/content_security_policy.h"
#include "services/network/public/cpp/no_vary_search_header_parser.h"
#include "services/network/public/cpp/parsed_headers.h"
#include "services/network/public/cpp/timing_allow_origin_parser.h"
#include "services/network/public/mojom/no_vary_search.mojom-blink-forward.h"
#include "services/network/public/mojom/no_vary_search.mojom-blink.h"
#include "services/network/public/mojom/parsed_headers.mojom-blink.h"
#include "services/network/public/mojom/supports_loading_mode.mojom-blink.h"
#include "services/network/public/mojom/timing_allow_origin.mojom-blink.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/mime_util/mime_util.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_response.h"
#include "third_party/blink/renderer/platform/network/header_field_tokenizer.h"
#include "third_party/blink/renderer/platform/network/http_names.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/date_math.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/parsing_utilities.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
namespace network {
namespace mojom {
uint8_t ConvertToBlink(uint8_t in) { … }
blink::CSPDirectiveName ConvertToBlink(CSPDirectiveName name) { … }
blink::WebClientHintsType ConvertToBlink(WebClientHintsType in) { … }
blink::LoadingMode ConvertToBlink(LoadingMode in) { … }
String ConvertToBlink(const std::string& in) { … }
String ConvertToBlink(const std::optional<std::string>& in) { … }
::blink::KURL ConvertToBlink(const GURL& in) { … }
scoped_refptr<const ::blink::SecurityOrigin> ConvertToBlink(
const url::Origin& in) { … }
template <
typename InElement,
typename OutElement = decltype(ConvertToBlink(std::declval<InElement>()))>
Vector<OutElement> ConvertToBlink(const std::vector<InElement>& in) { … }
template <typename InKey,
typename InValue,
typename OutKey = decltype(ConvertToBlink(std::declval<InKey>())),
typename OutValue = decltype(ConvertToBlink(std::declval<InValue>()))>
HashMap<OutKey, OutValue> ConvertToBlink(
const base::flat_map<InKey, InValue>& in) { … }
blink::CSPSourcePtr ConvertToBlink(const CSPSourcePtr& in) { … }
blink::CSPHashSourcePtr ConvertToBlink(const CSPHashSourcePtr& in) { … }
blink::CSPSourceListPtr ConvertToBlink(const CSPSourceListPtr& source_list) { … }
blink::ContentSecurityPolicyHeaderPtr ConvertToBlink(
const ContentSecurityPolicyHeaderPtr& in) { … }
blink::CSPTrustedTypesPtr ConvertToBlink(const CSPTrustedTypesPtr& in) { … }
blink::ContentSecurityPolicyPtr ConvertToBlink(
const ContentSecurityPolicyPtr& in) { … }
blink::AllowCSPFromHeaderValuePtr ConvertToBlink(
const AllowCSPFromHeaderValuePtr& allow_csp_from) { … }
blink::LinkHeaderPtr ConvertToBlink(const LinkHeaderPtr& in) { … }
blink::TimingAllowOriginPtr ConvertToBlink(const TimingAllowOriginPtr& in) { … }
blink::NoVarySearchWithParseErrorPtr ConvertToBlink(
const NoVarySearchWithParseErrorPtr& in) { … }
blink::ParsedHeadersPtr ConvertToBlink(const ParsedHeadersPtr& in) { … }
}
}
namespace blink {
namespace {
const Vector<AtomicString>& ReplaceHeaders() { … }
bool IsWhitespace(UChar chr) { … }
inline bool SkipWhiteSpace(const String& str,
unsigned& pos,
WTF::CharacterMatchFunctionPtr matcher = nullptr) { … }
template <typename CharType>
inline bool IsASCIILowerAlphaOrDigit(CharType c) { … }
template <typename CharType>
inline bool IsASCIILowerAlphaOrDigitOrHyphen(CharType c) { … }
bool ParseRefreshTime(const String& source, base::TimeDelta& delay) { … }
}
bool IsValidHTTPHeaderValue(const String& name) { … }
bool IsValidHTTPToken(const String& characters) { … }
bool IsContentDispositionAttachment(const String& content_disposition) { … }
bool ParseHTTPRefresh(const String& refresh,
WTF::CharacterMatchFunctionPtr matcher,
base::TimeDelta& delay,
String& url) { … }
std::optional<base::Time> ParseDate(const String& value) { … }
AtomicString ExtractMIMETypeFromMediaType(const AtomicString& media_type) { … }
bool IsHTTPTabOrSpace(UChar c) { … }
AtomicString MinimizedMIMEType(const AtomicString& mime_type) { … }
ContentTypeOptionsDisposition ParseContentTypeOptionsHeader(
const String& value) { … }
static bool IsCacheHeaderSeparator(UChar c) { … }
static bool IsControlCharacter(UChar c) { … }
static inline String TrimToNextSeparator(const String& str) { … }
static void ParseCacheHeader(const String& header,
Vector<std::pair<String, String>>& result) { … }
CacheControlHeader ParseCacheControlDirectives(
const AtomicString& cache_control_value,
const AtomicString& pragma_value) { … }
void ParseCommaDelimitedHeader(const String& header_value,
CommaDelimitedHeaderSet& header_set) { … }
bool ParseMultipartHeadersFromBody(const char* bytes,
wtf_size_t size,
ResourceResponse* response,
wtf_size_t* end) { … }
bool ParseMultipartFormHeadersFromBody(const char* bytes,
wtf_size_t size,
HTTPHeaderMap* header_fields,
wtf_size_t* end) { … }
bool ParseContentRangeHeaderFor206(const String& content_range,
int64_t* first_byte_position,
int64_t* last_byte_position,
int64_t* instance_length) { … }
std::unique_ptr<ServerTimingHeaderVector> ParseServerTimingHeader(
const String& headerValue) { … }
network::mojom::blink::ParsedHeadersPtr ParseHeaders(const String& raw_headers,
const KURL& url) { … }
Vector<network::mojom::blink::ContentSecurityPolicyPtr>
ParseContentSecurityPolicies(
const String& raw_policies,
network::mojom::blink::ContentSecurityPolicyType type,
network::mojom::blink::ContentSecurityPolicySource source,
const KURL& base_url) { … }
Vector<network::mojom::blink::ContentSecurityPolicyPtr>
ParseContentSecurityPolicies(
const String& raw_policies,
network::mojom::blink::ContentSecurityPolicyType type,
network::mojom::blink::ContentSecurityPolicySource source,
const SecurityOrigin& self_origin) { … }
Vector<network::mojom::blink::ContentSecurityPolicyPtr>
ParseContentSecurityPolicyHeaders(
const ContentSecurityPolicyResponseHeaders& headers) { … }
network::mojom::blink::TimingAllowOriginPtr ParseTimingAllowOrigin(
const String& header_value) { … }
network::mojom::blink::NoVarySearchWithParseErrorPtr ParseNoVarySearch(
const String& header_value) { … }
String GetNoVarySearchHintConsoleMessage(
const network::mojom::NoVarySearchParseError& error) { … }
}