Skip to content
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

Merged
merged 8 commits into from
Aug 15, 2019

Conversation

RudraniW
Copy link
Contributor

@RudraniW RudraniW commented Jul 9, 2019

Currently, cookies are sent as a part HTTPURLResponse headers. To access cookies, they have to be fished out of these headers. The getCookies(from: ) function takes HTTPURLResponse and returns HTTPCookie(s). New public property cookies is added into RestResponse structure. Cookies return by getCookies(from: )are added intocookies. The cookies can be accessed by accessing 'cookies property of RestResponse.

@@ -327,6 +327,23 @@ public class RestRequest: NSObject {
task.resume()
}
}
private func getCookies(from response: HTTPURLResponse?) -> [HTTPCookie]? {
guard let headers = response?.allHeaderFields else{

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 }

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 = [

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.

@RudraniW RudraniW force-pushed the restResponseCookies branch 2 times, most recently from a7dee31 to 6f3a02a Compare July 10, 2019 07:19
@RudraniW RudraniW requested a review from djones6 July 10, 2019 08:35
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
#endif
Copy link
Contributor

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)

@djones6
Copy link
Contributor

djones6 commented Jul 19, 2019

@RudraniW @pushkarnk is this ready to merge?

@pushkarnk
Copy link

@djones6 yes, I think we can merge

@djones6
Copy link
Contributor

djones6 commented Aug 15, 2019

CI is failing due to unrelated problem with Swift 5.1 (see #72) - so I'm going to merge this.

@djones6 djones6 merged commit c41343a into Kitura:master Aug 15, 2019
djones6 added a commit that referenced this pull request Sep 10, 2019
djones6 added a commit that referenced this pull request Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants