@@ -7,6 +7,9 @@ import Foundation
77public struct URLRequestData : Equatable , _EmptyInitializable {
88 /// The request body.
99 public var body : Data ?
10+
11+ /// The fragment subcomponent of the request URL.
12+ public var fragment : String ?
1013
1114 /// The request headers.
1215 ///
@@ -61,6 +64,7 @@ public struct URLRequestData: Equatable, _EmptyInitializable {
6164 /// - port: The port subcomponent of the request URL.
6265 /// - path: An array of the request URL's path components.
6366 /// - query: The query subcomponent of the request URL.
67+ /// - fragment: The fragment subcomponent of the request URL.
6468 /// - headers: The request headers.
6569 /// - body: The request body.
6670 @inlinable
@@ -73,10 +77,12 @@ public struct URLRequestData: Equatable, _EmptyInitializable {
7377 port: Int ? = nil ,
7478 path: String = " " ,
7579 query: [ String : [ String ? ] ] = [ : ] ,
80+ fragment: String ? = nil ,
7681 headers: [ String : [ String ? ] ] = [ : ] ,
7782 body: Data ? = nil
7883 ) {
7984 self . body = body
85+ self . fragment = fragment
8086 self . headers = . init( headers. mapValues { $0. map { $0 ? [ ... ] } [ ... ] } , isNameCaseSensitive: false )
8187 self . host = host
8288 self . method = method
@@ -147,6 +153,7 @@ extension URLRequestData: Codable {
147153 port: try container. decodeIfPresent ( Int . self, forKey: . port) ,
148154 path: try container. decodeIfPresent ( String . self, forKey: . path) ?? " " ,
149155 query: try container. decodeIfPresent ( [ String : [ String ? ] ] . self, forKey: . query) ?? [ : ] ,
156+ fragment: try container. decodeIfPresent ( String . self, forKey: . fragment) ,
150157 headers: try container. decodeIfPresent ( [ String : [ String ? ] ] . self, forKey: . headers) ?? [ : ] ,
151158 body: try container. decodeIfPresent ( Data . self, forKey: . body)
152159 )
@@ -156,6 +163,7 @@ extension URLRequestData: Codable {
156163 public func encode( to encoder: Encoder ) throws {
157164 var container = encoder. container ( keyedBy: CodingKeys . self)
158165 try container. encodeIfPresent ( self . body. map ( Array . init) , forKey: . body)
166+ try container. encodeIfPresent ( self . fragment, forKey: . fragment)
159167 if !self . headers. isEmpty {
160168 try container. encode (
161169 self . headers. fields. mapValues { $0. map { $0. map ( String . init) } } ,
@@ -180,6 +188,7 @@ extension URLRequestData: Codable {
180188 @usableFromInline
181189 enum CodingKeys : CodingKey {
182190 case body
191+ case fragment
183192 case headers
184193 case host
185194 case method
@@ -196,6 +205,7 @@ extension URLRequestData: Hashable {
196205 @inlinable
197206 public func hash( into hasher: inout Hasher ) {
198207 hasher. combine ( self . body)
208+ hasher. combine ( self . fragment)
199209 hasher. combine ( self . method)
200210 hasher. combine ( self . headers)
201211 hasher. combine ( self . host)
0 commit comments