chromium/services/network/public/mojom/no_vary_search.mojom

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module network.mojom;

// Describes the variance of URL query search params for cache matching
// purposes.
// For more information, see:
// https://wicg.github.io/nav-speculation/no-vary-search.html#model
union SearchParamsVariance {
  // Query parameters which should be ignored when comparing a request
  // to a cached response. This is empty if all query parameters are
  // significant.
  array<string> no_vary_params;
  // Query parameters which should be respected when comparing a request
  // to a cached response. This is empty if all query parameters should be
  // ignored.
  array<string> vary_params;
};

// The parsed value of the No-Vary-Search header.
// For more information, see:
// https://wicg.github.io/nav-speculation/no-vary-search.html#model
struct NoVarySearch {
  // Describes the variance of URL query search params for cache matching
  // purposes.
  // For more information, see:
  // https://wicg.github.io/nav-speculation/no-vary-search.html#model
  SearchParamsVariance search_variance;

  // If false, parameters with distinct keys can be reordered in order to find a
  // cache hit. Defaults to true.
  bool vary_on_key_order;
};

// Parse error encountered when parsing No-Vary-Search header value.
// The values are one to one with the parse error values in
// http_no_vary_search_data.h.
enum NoVarySearchParseError {
  kOk,                       // Parsing is correct.  Also returned if there is
                             // no header.
  kDefaultValue,             // Parsing is correct but led to default value.
                             // The header could be removed.
  kNotDictionary,            // Header value is not a dictionary.
  kUnknownDictionaryKey,     // Header value contains unknown dictionary keys.
  kNonBooleanKeyOrder,       // `key-order` is non-boolean.
  kParamsNotStringList,      // `params` is not a string list.
  kExceptNotStringList,      // `expect` is not a string list.
  kExceptWithoutTrueParams,  // `expect` without `params` set to true.
};

// The parsed value of No-Vary-Search header or the error
// encountered while parsing the header.
union NoVarySearchWithParseError {
  NoVarySearch no_vary_search;
  NoVarySearchParseError parse_error;
};