http_request_info.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_HTTP_HTTP_REQUEST_INFO_H__
  5. #define NET_HTTP_HTTP_REQUEST_INFO_H__
  6. #include <string>
  7. #include "base/memory/raw_ptr.h"
  8. #include "net/base/idempotency.h"
  9. #include "net/base/net_export.h"
  10. #include "net/base/network_isolation_key.h"
  11. #include "net/base/privacy_mode.h"
  12. #include "net/dns/public/secure_dns_policy.h"
  13. #include "net/http/http_request_headers.h"
  14. #include "net/socket/socket_tag.h"
  15. #include "net/traffic_annotation/network_traffic_annotation.h"
  16. #include "third_party/abseil-cpp/absl/types/optional.h"
  17. #include "url/gurl.h"
  18. #include "url/origin.h"
  19. namespace net {
  20. class UploadDataStream;
  21. struct NET_EXPORT HttpRequestInfo {
  22. HttpRequestInfo();
  23. HttpRequestInfo(const HttpRequestInfo& other);
  24. ~HttpRequestInfo();
  25. // The requested URL.
  26. GURL url;
  27. // The method to use (GET, POST, etc.).
  28. std::string method;
  29. // This key is used to isolate requests from different contexts in accessing
  30. // shared network resources like the cache.
  31. NetworkIsolationKey network_isolation_key;
  32. // True if it is a subframe's document resource.
  33. bool is_subframe_document_resource = false;
  34. // Any extra request headers (including User-Agent).
  35. HttpRequestHeaders extra_headers;
  36. // Any upload data.
  37. raw_ptr<UploadDataStream> upload_data_stream = nullptr;
  38. // Any load flags (see load_flags.h).
  39. int load_flags = 0;
  40. // If enabled, then request must be sent over connection that cannot be
  41. // tracked by the server (e.g. without channel id).
  42. PrivacyMode privacy_mode = PRIVACY_MODE_DISABLED;
  43. // Secure DNS Tag for the request.
  44. SecureDnsPolicy secure_dns_policy = SecureDnsPolicy::kAllow;
  45. // Tag applied to all sockets used to service request.
  46. SocketTag socket_tag;
  47. // Network traffic annotation received from URL request.
  48. net::MutableNetworkTrafficAnnotationTag traffic_annotation;
  49. // Reporting upload nesting depth of this request.
  50. //
  51. // If the request is not a Reporting upload, the depth is 0.
  52. //
  53. // If the request is a Reporting upload, the depth is the max of the depth
  54. // of the requests reported within it plus 1.
  55. int reporting_upload_depth = 0;
  56. // This may the top frame origin associated with a request, or it may be the
  57. // top frame site. Or it may be nullptr. Only used for histograms.
  58. //
  59. // TODO(https://crbug.com/1136054): Investigate migrating the one consumer of
  60. // this to NetworkIsolationKey::TopFrameSite(). That gives more consistent
  61. /// behavior, and may still provide useful metrics.
  62. absl::optional<url::Origin> possibly_top_frame_origin;
  63. // Idempotency of the request, which determines that if it is safe to enable
  64. // 0-RTT for the request. By default, 0-RTT is only enabled for safe
  65. // HTTP methods, i.e., GET, HEAD, OPTIONS, and TRACE. For other methods,
  66. // enabling 0-RTT may cause security issues since a network observer can
  67. // replay the request. If the request has any side effects, those effects can
  68. // happen multiple times. It is only safe to enable the 0-RTT if it is known
  69. // that the request is idempotent.
  70. net::Idempotency idempotency = net::DEFAULT_IDEMPOTENCY;
  71. // Index of the requested URL in Cache Transparency's pervasive payload list.
  72. // Only used for logging purposes.
  73. int pervasive_payloads_index_for_logging = -1;
  74. // Checksum of the request body and selected headers, in upper-case
  75. // hexadecimal. Only non-empty if the USE_SINGLE_KEYED_CACHE load flag is set.
  76. std::string checksum;
  77. };
  78. } // namespace net
  79. #endif // NET_HTTP_HTTP_REQUEST_INFO_H__