File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -275,9 +275,9 @@ open class Client {
275
275
func complete(with response: HTTPClientResponse) async throws -> T {
276
276
switch response.status.code {
277
277
case 0..<400:
278
- if response .headers [" cookies " ].count > 0 {
278
+ if response .headers [" Set-Cookie " ].count > 0 {
279
279
UserDefaults.standard.set(
280
- try! response.headers["cookies"].toJson() ,
280
+ response.headers["Set-Cookie"] ,
281
281
forKey: URL(string: request.url)!.host! + "-cookies"
282
282
)
283
283
}
Original file line number Diff line number Diff line change @@ -17,16 +17,11 @@ extension HTTPClientRequest {
17
17
18
18
extension HTTPHeaders {
19
19
public mutating func addDomainCookies(for domain: String) {
20
- let cookieJson = UserDefaults.standard.string(forKey: "\(domain)-cookies")
21
- let cookies: [HTTPClient.Cookie?]? = try? cookieJson?.fromJson(to: [HTTPClient.Cookie].self)
22
- ?? [(try? cookieJson?.fromJson(to: HTTPClient.Cookie.self))]
23
-
24
- var cookiesValue = ""
25
- for cookie in cookies ?? [] {
26
- if let cookie = cookie {
27
- cookiesValue += "\(cookie.name)=\(cookie.value);"
28
- }
20
+ guard let cookies = UserDefaults.standard.stringArray(forKey: "\(domain)-cookies") else {
21
+ return
22
+ }
23
+ for cookie in cookies {
24
+ add(name: "Cookie", value: cookie)
29
25
}
30
- add(name: "Cookie", value: cookiesValue)
31
26
}
32
27
}
You can’t perform that action at this time.
0 commit comments