• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_HTTP_HTTP_REQUEST_INFO_H__
6 #define NET_HTTP_HTTP_REQUEST_INFO_H__
7 
8 #include <optional>
9 #include <string>
10 
11 #include "base/functional/callback_forward.h"
12 #include "base/memory/raw_ptr.h"
13 #include "net/base/idempotency.h"
14 #include "net/base/net_export.h"
15 #include "net/base/network_anonymization_key.h"
16 #include "net/base/network_isolation_key.h"
17 #include "net/base/privacy_mode.h"
18 #include "net/base/request_priority.h"
19 #include "net/dns/public/secure_dns_policy.h"
20 #include "net/http/http_request_headers.h"
21 #include "net/shared_dictionary/shared_dictionary.h"
22 #include "net/shared_dictionary/shared_dictionary_getter.h"
23 #include "net/socket/socket_tag.h"
24 #include "net/traffic_annotation/network_traffic_annotation.h"
25 #include "url/gurl.h"
26 #include "url/origin.h"
27 
28 namespace net {
29 
30 class UploadDataStream;
31 
32 struct NET_EXPORT HttpRequestInfo {
33   HttpRequestInfo();
34 
35   HttpRequestInfo(const HttpRequestInfo& other);
36   HttpRequestInfo& operator=(const HttpRequestInfo& other);
37   HttpRequestInfo(HttpRequestInfo&& other);
38   HttpRequestInfo& operator=(HttpRequestInfo&& other);
39 
40   ~HttpRequestInfo();
41 
42   bool IsConsistent() const;
43 
44   // The requested URL.
45   GURL url;
46 
47   // The method to use (GET, POST, etc.).
48   std::string method;
49 
50   // This key is used to isolate requests from different contexts in accessing
51   // shared cache.
52   NetworkIsolationKey network_isolation_key;
53 
54   // This key is used to isolate requests from different contexts in accessing
55   // shared network resources.
56   NetworkAnonymizationKey network_anonymization_key;
57 
58   // True if it is a subframe's document resource.
59   bool is_subframe_document_resource = false;
60 
61   // True if it is a main frame navigation.
62   bool is_main_frame_navigation = false;
63 
64   // Any extra request headers (including User-Agent).
65   HttpRequestHeaders extra_headers;
66 
67   // Any upload data.
68   raw_ptr<UploadDataStream> upload_data_stream = nullptr;
69 
70   // Any load flags (see load_flags.h).
71   int load_flags = 0;
72 
73   // Flag that indicates if the request should be loaded concurrently with
74   // other requests of the same priority when using a protocol that supports
75   // HTTP extensible priorities (RFC 9218). Currently only HTTP/3.
76   bool priority_incremental = kDefaultPriorityIncremental;
77 
78   // If enabled, then request must be sent over connection that cannot be
79   // tracked by the server (e.g. without channel id).
80   PrivacyMode privacy_mode = PRIVACY_MODE_DISABLED;
81 
82   // Secure DNS Tag for the request.
83   SecureDnsPolicy secure_dns_policy = SecureDnsPolicy::kAllow;
84 
85   // Tag applied to all sockets used to service request.
86   SocketTag socket_tag;
87 
88   // Network traffic annotation received from URL request.
89   MutableNetworkTrafficAnnotationTag traffic_annotation;
90 
91   // Reporting upload nesting depth of this request.
92   //
93   // If the request is not a Reporting upload, the depth is 0.
94   //
95   // If the request is a Reporting upload, the depth is the max of the depth
96   // of the requests reported within it plus 1.
97   int reporting_upload_depth = 0;
98 
99   // This may the top frame origin associated with a request, or it may be the
100   // top frame site.  Or it may be nullptr.  Only used for histograms.
101   //
102   // TODO(crbug.com/40724003): Investigate migrating the one consumer of
103   // this to NetworkIsolationKey::TopFrameSite().  That gives more consistent
104   /// behavior, and may still provide useful metrics.
105   std::optional<url::Origin> possibly_top_frame_origin;
106 
107   // The frame origin associated with a request. This is used to isolate shared
108   // dictionaries between different frame origins.
109   std::optional<url::Origin> frame_origin;
110 
111   // The origin of the context which initiated this request. nullptr for
112   // browser-initiated navigations. For more info, see
113   // `URLRequest::initiator()`.
114   std::optional<url::Origin> initiator;
115 
116   // Idempotency of the request, which determines that if it is safe to enable
117   // 0-RTT for the request. By default, 0-RTT is only enabled for safe
118   // HTTP methods, i.e., GET, HEAD, OPTIONS, and TRACE. For other methods,
119   // enabling 0-RTT may cause security issues since a network observer can
120   // replay the request. If the request has any side effects, those effects can
121   // happen multiple times. It is only safe to enable the 0-RTT if it is known
122   // that the request is idempotent.
123   Idempotency idempotency = DEFAULT_IDEMPOTENCY;
124 
125   // If not null, the value is used to evaluate whether the cache entry should
126   // be bypassed; if is null, that means the request site does not match the
127   // filter.
128   std::optional<int64_t> fps_cache_filter;
129 
130   // Use as ID to mark the cache entry when persisting. Should be a positive
131   // number once set.
132   std::optional<int64_t> browser_run_id;
133 
134   // Used to get a shared dictionary for the request. This may be null if the
135   // request does not use a shared dictionary.
136   SharedDictionaryGetter dictionary_getter;
137 };
138 
139 }  // namespace net
140 
141 #endif  // NET_HTTP_HTTP_REQUEST_INFO_H__
142