Skip to content

Commit

Permalink
Merge pull request #408 from icflix/goliath-headers
Browse files Browse the repository at this point in the history
goliath passes request header keys as symbols
  • Loading branch information
dblock committed Jun 2, 2013
2 parents 93a153a + ad4c2e7 commit 948696f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Next Release
* [#241](https://github.com/intridea/grape/issues/241): Present with multiple entities using an optional Symbol - [@niedhui](https://github.com/niedhui).
* [#412](https://github.com/intridea/grape/issues/412): Fix: specifying `content_type` will also override the selection of the data formatter - [@dblock](https://github.com/dblock).
* [#383](https://github.com/intridea/grape/issues/383): Fix: Mounted APIs aren't inheriting settings (including `before` and `after` filters) - [@seanmoon](https://github.com/seanmoon).
* [#408](https://github.com/intridea/grape/pull/408): Fix: Goliath passes request header keys as symbols not strings - [@bobek](https://github.com/bobek).
* Your contribution here.

0.4.1 (4/1/2013)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def params

def headers
@env['grape.request.headers'] ||= @env.dup.inject({}) { |h, (k, v)|
if k.start_with? 'HTTP_'
if k.to_s.start_with? 'HTTP_'
k = k[5..-1].gsub('_', '-').downcase.gsub(/^.|[-_\s]./) { |x| x.upcase }
h[k] = v
end
Expand Down
6 changes: 6 additions & 0 deletions spec/grape/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def app; subject end
get '/headers', nil, { "HTTP_X_GRAPE_CLIENT" => "1" }
JSON.parse(last_response.body)["X-Grape-Client"].should == "1"
end
it 'includes headers passed as symbols' do
env = Rack::MockRequest.env_for("/headers")
env[:HTTP_SYMBOL_HEADER] = "Goliath passes symbols"
body = subject.call(env)[2].body.first
JSON.parse(body)["Symbol-Header"].should == "Goliath passes symbols"
end
end

describe '#cookies' do
Expand Down

0 comments on commit 948696f

Please sign in to comment.