-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace to HTTPTypes Components from Helpers Components (#564)
* add HTTPTypes * replace to HTTPFields from HTTPHeader * replace to HTTPTypes.HTTPRequest.Method from HTTPMethod * fix Test * add setHeader(name: String, value: String) -> Self
- Loading branch information
1 parent
5786dd6
commit 71dee2a
Showing
31 changed files
with
242 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import HTTPTypes | ||
|
||
package extension HTTPFields { | ||
init(_ dictionary: [String: String]) { | ||
self.init(dictionary.map { .init(name: .init($0.key)!, value: $0.value) }) | ||
} | ||
|
||
var dictionary: [String: String] { | ||
let keyValues = self.map { | ||
($0.name.rawName, $0.value) | ||
} | ||
|
||
return .init(keyValues, uniquingKeysWith: { $1 }) | ||
} | ||
|
||
mutating func merge(with other: Self) { | ||
for field in other { | ||
self[field.name] = field.value | ||
} | ||
} | ||
|
||
func merging(with other: Self) -> Self { | ||
var copy = self | ||
|
||
for field in other { | ||
copy[field.name] = field.value | ||
} | ||
|
||
return copy | ||
} | ||
} | ||
|
||
package extension HTTPField.Name { | ||
static let xClientInfo = HTTPField.Name("X-Client-Info")! | ||
static let xRegion = HTTPField.Name("x-region")! | ||
static let xRelayError = HTTPField.Name("x-relay-error")! | ||
} |
Oops, something went wrong.