Skip to content

Commit

Permalink
Delete #body method from Rack request gateway and fixed content-length
Browse files Browse the repository at this point in the history
  • Loading branch information
vpellan committed Sep 27, 2024
1 parent 74363cc commit 304e43f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Matrixfile
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
'redis-5' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
'appsec:rack' => {
# 'rack-latest' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
'rack-latest' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
'rack-3' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
'rack-2' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
# Non-deprecated form of Regexp.new does not backport to Rack 1.x, see: https://github.com/rack/rack/pull/1998
Expand Down
7 changes: 2 additions & 5 deletions lib/datadog/appsec/contrib/rack/gateway/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ def headers
end

result['content-type'] = request.content_type if request.content_type
result['content-length'] = request.content_length if request.content_length
# Since Rack 3.1, content-length is nil if the body is empty, but we still want to send it to the WAF.
result['content-length'] = request.content_length || '0'
result
end

def body
request.body.read.tap { request.body.rewind }
end

def url
request.url
end
Expand Down
6 changes: 0 additions & 6 deletions spec/datadog/appsec/contrib/rack/gateway/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@
end
end

describe '#body' do
it 'returns the body' do
expect(request.body).to eq('')
end
end

describe '#url' do
it 'returns the url' do
expect(request.url).to eq('http://example.com:8080/?a=foo&a=bar&b=baz')
Expand Down

0 comments on commit 304e43f

Please sign in to comment.