Skip to content

Commit

Permalink
Merge pull request #203 from mamantoha/fix/response-headers
Browse files Browse the repository at this point in the history
Do not merge request headers into response
  • Loading branch information
mamantoha authored Jan 22, 2023
2 parents d40b2ce + e63b376 commit 3a7eeb2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion spec/integration/cookies_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe Crest do
(response.url).should eq("#{TEST_SERVER_URL}/get")
(response.status_code).should eq(200)
(response.cookies).should eq({"k1" => "v1", "k2" => "v2"})
(response.headers.[]("Cookie")).should eq("k1=v1; k2=v2")
(JSON.parse(response.body)["cookies"]).should eq({"k1" => "v1", "k2" => "v2"})
(JSON.parse(response.body)["headers"]["Cookie"]).should eq("k1=v1; k2=v2")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/headers_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ describe Crest do
it "should set headers" do
response = Crest.get("#{TEST_SERVER_URL}/get", headers: {"Access-Token" => ["secret1", "secret2"]})
(response.status_code).should eq(200)
(response.headers.[]("Access-Token")).should eq(["secret1", "secret2"])
(JSON.parse(response.body)["headers"]["Access-Token"]).should eq("secret1;secret2")
response.headers.should_not contain("Access-Token")
end

it "should get request headers" do
Expand Down
4 changes: 1 addition & 3 deletions src/crest/response.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ module Crest
end

def headers
headers = @request.headers.dup.merge!(http_client_res.headers)

normalize_headers(headers)
normalize_headers(http_client_res.headers)
end

def cookies
Expand Down

0 comments on commit 3a7eeb2

Please sign in to comment.