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

Refactor `#cookie` API #536

Open
ixti opened this issue Mar 5, 2019 · 3 comments
Open

Refactor `#cookie` API #536

ixti opened this issue Mar 5, 2019 · 3 comments
Labels
Milestone

Comments

@ixti
Copy link
Member

@ixti ixti commented Mar 5, 2019

  1. HTTP::Response#cookies must return Array<HTTP::Cookies> - not jar.
  2. HTTP::Client#cookies should be either eliminated (IMO that's the best options) or become just a simple way of adding Cookie: header with no magic of cookies concatenation involved.

/cc @httprb/core

@ixti ixti added the Discussion label Mar 5, 2019
@ixti
Copy link
Member Author

@ixti ixti commented Mar 5, 2019

Right now #cookies passing is somewhat weird (IMO):

def cookie_header(response)
  response.parse(:json).dig("headers", "Cookie")
end

http = HTTP.cookies(:a => 1, :b => 2).cookies(:a => 3)
cookie_header http.get("https://httpbin.org/headers")
# => "a=3; b=2"

cookie_header http.get("https://httpbin.org/headers", :cookies => { :a => 4 })
# => "4"

http = http.headers("Cookie" => "a=1;f=6")
cookie_header http.get("https://httpbin.org/headers")
# "a=1;f=6; a=3; b=2"

cookie_header http.get("https://httpbin.org/headers", :cookies => { :a => 4 })
# "a=1;f=6; 4"
@tarcieri
Copy link
Member

@tarcieri tarcieri commented Mar 5, 2019

The CookieJar integration is definitely screwed up, and belongs on a hypothetical session type (#306), IMO.

I would agree with your assessment that this API needs changed and is presently awkward/asymmetrical.

@ixti
Copy link
Member Author

@ixti ixti commented Mar 5, 2019

Yes. Full cookie management belongs to session class. Here we should make it straight forward and simple to just pass cookies in and out.

@ixti ixti added this to the v5.0.0 milestone Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.