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