• 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 <string>
9 
10 #include "base/memory/raw_ptr.h"
11 #include "net/base/idempotency.h"
12 #include "net/base/net_export.h"
13 #include "net/base/network_anonymization_key.h"
14 #include "net/base/network_isolation_key.h"
15 #include "net/base/privacy_mode.h"
16 #include "net/base/request_priority.h"
17 #include "net/dns/public/secure_dns_policy.h"
18 #include "net/http/http_request_headers.h"
19 #include "net/socket/socket_tag.h"
20 #include "net/traffic_annotation/network_traffic_annotation.h"
21 #include "third_party/abseil-cpp/absl/types/optional.h"
22 #include "url/gurl.h"
23 #include "url/origin.h"
24 
25 namespace net {
26 
27 class UploadDataStream;
28 
29 struct NET_EXPORT HttpRequestInfo {
30   HttpRequestInfo();
31   HttpRequestInfo(const HttpRequestInfo& other);
32   ~HttpRequestInfo();
33 
34   bool IsConsistent() const;
35 
36   // The requested URL.
37   GURL url;
38 
39   // The method to use (GET, POST, etc.).
40   std::string method;
41 
42   // This key is used to isolate requests from different contexts in accessing
43   // shared cache.
44   NetworkIsolationKey network_isolation_key;
45 
46   // This key is used to isolate requests from different contexts in accessing
47   // shared network resources.
48   NetworkAnonymizationKey network_anonymization_key;
49 
50   // True if it is a subframe's document resource.
51   bool is_subframe_document_resource = false;
52 
53   // Any extra request headers (including User-Agent).
54   HttpRequestHeaders extra_headers;
55 
56   // Any upload data.
57   raw_ptr<UploadDataStream, DanglingUntriaged> upload_data_stream = nullptr;
58 
59   // Any load flags (see load_flags.h).
60   int load_flags = 0;
61 
62   // Flag that indicates if the request should be loaded concurrently with
63   // other requests of the same priority when using a protocol that supports
64   // HTTP extensible priorities (RFC 9218). Currently only HTTP/3.
65   bool priority_incremental = kDefaultPriorityIncremental;
66 
67   // If enabled, then request must be sent over connection that cannot be
68   // tracked by the server (e.g. without channel id).
69   PrivacyMode privacy_mode = PRIVACY_MODE_DISABLED;
70 
71   // Secure DNS Tag for the request.
72   SecureDnsPolicy secure_dns_policy = SecureDnsPolicy::kAllow;
73 
74   // Tag applied to all sockets used to service request.
75   SocketTag socket_tag;
76 
77   // Network traffic annotation received from URL request.
78   net::MutableNetworkTrafficAnnotationTag traffic_annotation;
79 
80   // Reporting upload nesting depth of this request.
81   //
82   // If the request is not a Reporting upload, the depth is 0.
83   //
84   // If the request is a Reporting upload, the depth is the max of the depth
85   // of the requests reported within it plus 1.
86   int reporting_upload_depth = 0;
87 
88   // This may the top frame origin associated with a request, or it may be the
89   // top frame site.  Or it may be nullptr.  Only used for histograms.
90   //
91   // TODO(https://crbug.com/1136054): Investigate migrating the one consumer of
92   // this to NetworkIsolationKey::TopFrameSite().  That gives more consistent
93   /// behavior, and may still provide useful metrics.
94   absl::optional<url::Origin> possibly_top_frame_origin;
95 
96   // Idempotency of the request, which determines that if it is safe to enable
97   // 0-RTT for the request. By default, 0-RTT is only enabled for safe
98   // HTTP methods, i.e., GET, HEAD, OPTIONS, and TRACE. For other methods,
99   // enabling 0-RTT may cause security issues since a network observer can
100   // replay the request. If the request has any side effects, those effects can
101   // happen multiple times. It is only safe to enable the 0-RTT if it is known
102   // that the request is idempotent.
103   net::Idempotency idempotency = net::DEFAULT_IDEMPOTENCY;
104 
105   // Index of the requested URL in Cache Transparency's pervasive payload list.
106   // Only used for logging purposes.
107   int pervasive_payloads_index_for_logging = -1;
108 
109   // Checksum of the request body and selected headers, in upper-case
110   // hexadecimal. Only non-empty if the USE_SINGLE_KEYED_CACHE load flag is set.
111   std::string checksum;
112 
113   // If not null, the value is used to evaluate whether the cache entry should
114   // be bypassed; if is null, that means the request site does not match the
115   // filter.
116   absl::optional<int64_t> fps_cache_filter;
117 
118   // Use as ID to mark the cache entry when persisting. Should be a positive
119   // number once set.
120   absl::optional<int64_t> browser_run_id;
121 };
122 
123 }  // namespace net
124 
125 #endif  // NET_HTTP_HTTP_REQUEST_INFO_H__
126