Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ Optional settings
AdminMailer.email_admins("Oh god, it's on fire!").deliver_later
}

.. describe:: truncate_http_body

By default the HTTP body of a request is truncated to 2048 characters. It can be disabled.

.. code-block:: ruby

config.truncate_http_body = false

Environment Variables
---------------------

Expand Down
4 changes: 4 additions & 0 deletions lib/raven/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class Configuration
# E.g. lambda { |event| Thread.new { MyJobProcessor.send_email(event) } }
attr_reader :transport_failure_callback

# Enables HTTP body truncation when true (default).
attr_accessor :truncate_http_body

# Errors object - an Array that contains error messages. See #
attr_reader :errors

Expand Down Expand Up @@ -206,6 +209,7 @@ def initialize
self.tags = {}
self.timeout = 2
self.transport_failure_callback = false
self.truncate_http_body = true
self.sanitize_data_for_request_methods = DEFAULT_REQUEST_METHODS_FOR_DATA_SANITIZATION.dup
end

Expand Down
4 changes: 3 additions & 1 deletion lib/raven/integrations/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def read_data_from(request)
if request.form_data?
request.POST
elsif request.body # JSON requests, etc
data = request.body.read(2048) # Sentry server limit
length = 2048 if Raven.configuration.truncate_http_body

data = request.body.read(length)
request.body.rewind
data
end
Expand Down
14 changes: 14 additions & 0 deletions spec/raven/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@
it "truncates http data" do
expect(hash[:request][:data]).to eq("a" * 2048)
end

context "with truncation disabled" do
before(:each) do
Raven.configuration.truncate_http_body = false
end

after(:each) do
Raven.configuration.truncate_http_body = true
end

it "does not truncate http data" do
expect(hash[:request][:data]).to eq("a" * 16_000)
end
end
end

context 'configuration tags specified' do
Expand Down