Skip to content

Commit

Permalink
Abstracting request on body always returning data.length on curb adapter
Browse files Browse the repository at this point in the history
Following @chetan suggestion on PR #71
  • Loading branch information
rogerleite committed Jul 24, 2013
1 parent 0feaf85 commit 6ca1151
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/httpi/adapter/curb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ def request(method)
arguments << (@request.body || "")
end

client.on_body(&@request.on_body) if @request.on_body
if @request.on_body
client.on_body do |data|
@request.on_body.call(data)
# curb requires you to return the length of the data read from the block.
# It allows you to abort the connection by returning a smaller value
data.length
end
end

do_request { |client| client.send(*arguments) }
rescue Curl::Err::SSLCACertificateError
Expand Down

0 comments on commit 6ca1151

Please sign in to comment.