user3219596
user3219596

Reputation: 133

Cannot set two or more cookies in HTTPoison

when I try to set 2 or more cookies I give only the first one

case HTTPoison.get("https://httpbin.org/cookies", %{}, hackney: [cookie: [{"cookie1", "1"} , {"cookie2", "2"}]]) do

{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
IO.puts body
{_, %HTTPoison.Response{status_code: _, body: _}} ->
# Nothing to do
end
end

The answer from the page:

{
  "cookies": {
    "cookie1": "1"
  }
}

(Sorry for eventually mistakes, i cleanup a complex code for write here) :)

Upvotes: 2

Views: 360

Answers (1)

Dmytro Biletskyi
Dmytro Biletskyi

Reputation: 1903

I'm not sure why your example does not work, but hackney can receive cookies in binary format.

case HTTPoison.get("https://httpbin.org/cookies", %{}, hackney: [cookie: "cookie1=111; cookie2=222"]) do
  {:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
  IO.puts body
end

responce

{
  "cookies": {
    "cookie1": "111",
    "cookie2": "222"
  }
}

Upvotes: 3

Related Questions