summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/blink/public/mojom/fetch/fetch_api_response.mojom
blob: 678de941eb358681265dee0ca61018c6f8cb3c7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

import "mojo/public/mojom/base/time.mojom";
import "services/network/public/mojom/fetch_api.mojom";
import "services/network/public/mojom/parsed_headers.mojom";
import "services/network/public/mojom/network_types.mojom";
import "third_party/blink/public/mojom/blob/serialized_blob.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_error_type.mojom";
import "url/mojom/url.mojom";

// Describes a Response in terms of the concept from the Fetch spec.
// https://fetch.spec.whatwg.org/#response-class
// Note: Be sure to update CacheStorageCache::EstimatedResponseSizeWithoutBlob()
// when adding or removing members.
struct FetchAPIResponse {
  // List of URLs that originally generated this response, it includes all URLs
  // in case of HTTP redirect, first URL on redirect chain is on position 0.
  // It can be empty if respones was generated programatically as in
  // responsdWith(new Response()).
  array<url.mojom.Url> url_list;

  // Status code as number, e.g.: 200, 404.
  // Zero status code indicates an error happened and the request was not
  // handled.
  uint16 status_code = 0;

  // Status code as text. e.g.: "OK", "Not Found".
  string status_text;

  // Corresponds to response types from the Fetch spec:
  // https://fetch.spec.whatwg.org/#concept-response-type
  network.mojom.FetchResponseType response_type =
    network.mojom.FetchResponseType.kDefault;

  // The source of this response, e.g. network, CacheStorage.
  network.mojom.FetchResponseSource response_source =
    network.mojom.FetchResponseSource.kUnspecified;

  // The response headers. It's case insensitive for header name as key.
  map<string, string> headers;

  // The mime type of the response, if one has been set.
  string? mime_type;

  // The http request method used to load the response.  May be unset for
  // synthetic Response objects created via the constructor.
  string? request_method;

  // Mojo interface to read the response payload.
  SerializedBlob? blob;

  // Error codes for service worker APIs.
  ServiceWorkerResponseError error =
    blink.mojom.ServiceWorkerResponseError.kUnknown;

  // The time at which the response headers were received.  For cached
  // responses, this time could be "far" in the past.
  mojo_base.mojom.Time response_time;

  // Name of cache where this response was retrieved, empty otherwise.
  string? cache_storage_cache_name;

  // In case this is a CORS response fetched by a ServiceWorker, this is the
  // set of headers that should be exposed.
  array<string> cors_exposed_header_names;

  // Used to pass code cache for responses produced by cache_storage.  The code
  // cache will be stored in the side data stream of the blob.
  SerializedBlob? side_data_blob;

  // Used to pass code cache for a response that is being newly stored in
  // cache_storage.  This blob is created from a memory buffer in the renderer
  // and the code cache is contained in the primary data stream of the blob.
  SerializedBlob? side_data_blob_for_cache_put;

  // A set of parsed headers for clients that can't do the parsing themselves,
  // because they aren't sandboxed (e.g. the browser process). This is the
  // output of blink::ParseHeaders(headers, url);
  network.mojom.ParsedHeaders? parsed_headers;

  // Enumeration that describes the kind of connection originally used to
  // fetch this request.
  network.mojom.ConnectionInfo connection_info;

  // ALPN negotiated protocol of the socket which fetched this resource.
  string alpn_negotiated_protocol = "unknown";

  // True if the response was loaded with a Request where the credentials mode
  // would potentially send cookies to the server:
  //
  //  https://fetch.spec.whatwg.org/#requestcredentials
  //
  // For example, if RequestCredentials is 'include' this field will be true.
  // If RequestCredentials is 'same-origin', but the Response was loaded
  // cross-origin then this field will be false.
  //
  // This field may be true even if there were no cookies actually available
  // to send.
  bool loaded_with_credentials = false;

  // True if the response was originally loaded via a request fetched over a
  // SPDY channel.
  bool was_fetched_via_spdy = false;

  // https://fetch.spec.whatwg.org/#concept-response-range-requested-flag
  bool has_range_requested = false;
};