-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An easy way to access cookies in RestResponse #68
Conversation
d589cca
to
8b236e7
Compare
@@ -327,6 +327,23 @@ public class RestRequest: NSObject { | |||
task.resume() | |||
} | |||
} | |||
private func getCookies(from response: HTTPURLResponse?) -> [HTTPCookie]? { | |||
guard let headers = response?.allHeaderFields else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation: space after else
var headerFields = [String : String]() | ||
for (key, value) in headers{ | ||
guard let key = key as? String, let value = value as? String else{ | ||
continue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the indentation here.
let number = request.parameters["number"].map { Int($0) ?? 0 } ?? 0 | ||
for no in 0..<number { | ||
var cookieProps: [HTTPCookiePropertyKey: Any] | ||
cookieProps = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the indentation here.
a7dee31
to
6f3a02a
Compare
#if canImport(FoundationNetworking) | ||
import FoundationNetworking | ||
#endif | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this block already present below?
(this might be a merge issue with #67)
@RudraniW @pushkarnk is this ready to merge? |
@djones6 yes, I think we can merge |
a9ebc0e
to
c7ef508
Compare
CI is failing due to unrelated problem with Swift 5.1 (see #72) - so I'm going to merge this. |
Currently, cookies are sent as a part
HTTPURLResponse
headers. To access cookies, they have to be fished out of these headers. ThegetCookies(from: )
function takesHTTPURLResponse
and returns HTTPCookie(s). New public propertycookies
is added intoRestResponse
structure. Cookies return by getCookies(from: )are added into
cookies. The cookies can be accessed by accessing 'cookies
property ofRestResponse
.