Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactor `#cookie` API #536
Open
Labels
Milestone
Comments
|
Right now 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" |
|
The I would agree with your assessment that this API needs changed and is presently awkward/asymmetrical. |
|
Yes. Full cookie management belongs to session class. Here we should make it straight forward and simple to just pass cookies in and out. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HTTP::Response#cookiesmust returnArray<HTTP::Cookies>- not jar.HTTP::Client#cookiesshould be either eliminated (IMO that's the best options) or become just a simple way of addingCookie:header with no magic of cookies concatenation involved./cc @httprb/core