Skip to content

Commit

Permalink
fix: use .read instead of .string for reading stream from rack.input
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 19, 2023
1 parent 022be6c commit 000e3fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pact/mock_service/request_handlers/interactions_put.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def request_method
end

def respond env
request_body = JSON.load(env['rack.input'].string)
request_body = JSON.load(env['rack.input'].read)
parsing_options = { pact_specification_version: pact_specification_version }
interactions = request_body['interactions'].collect { | hash | Interaction.from_hash(hash, parsing_options) }
begin
Expand Down
2 changes: 1 addition & 1 deletion lib/pact/mock_service/request_handlers/pact_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def request_method
end

def respond env
body = env['rack.input'].string
body = env['rack.input'].read
consumer_contract_details = body.size > 0 ? JSON.parse(body, symbolize_names: true) : {}
consumer_contract_params = default_options.merge(consumer_contract_details.merge(interactions: verified_interactions))
consumer_contract_writer = ConsumerContractWriter.new(consumer_contract_params, logger)
Expand Down

0 comments on commit 000e3fd

Please sign in to comment.