Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added the possibility to specify a body_stream in HttpRequest #275

Merged
merged 2 commits into from

2 participants

@klobuczek

This is very simple yet very useful addition to allow streaming to a REST server. References Issue #168: #168

@jnunemaker
Owner

Could you add a test of some sort for this to ensure that no one breaks it in the future. Thanks!

@klobuczek

Added a spec that verifies that part of request configuration.

@jnunemaker jnunemaker merged commit 2ea1499 into jnunemaker:master
@klobuczek

Would you mind pushing this pull request to rubygems.org? Our company deployment proxy disallows accessing github so we had to replicate the repository to our own git server, which I would prefer not to maintain.
Thanks

@jnunemaker
Owner

Done.

@jnunemaker
Owner

0.13.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2014
  1. @klobuczek
Commits on Mar 5, 2014
  1. @klobuczek
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 0 deletions.
  1. +1 −0  lib/httparty/request.rb
  2. +7 −0 spec/httparty/request_spec.rb
View
1  lib/httparty/request.rb
@@ -148,6 +148,7 @@ def query_string_normalizer
def setup_raw_request
@raw_request = http_method.new(request_uri(uri))
@raw_request.body = body if body
+ @raw_request.body_stream = options[:body_stream] if options[:body_stream]
@raw_request.initialize_http_header(options[:headers])
@raw_request.basic_auth(username, password) if options[:basic_auth]
setup_digest_auth if options[:digest_auth]
View
7 spec/httparty/request_spec.rb
@@ -117,6 +117,13 @@
@post_request.options[:digest_auth] = {:username => 'foobar', :password => 'secret'}
@post_request.send(:setup_raw_request)
end
+
+ it 'should use body_stream when configured' do
+ stream = StringIO.new('foo')
+ request = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body_stream: stream)
+ request.send(:setup_raw_request)
+ request.instance_variable_get(:@raw_request).body_stream.should == stream
+ end
end
describe "#uri" do
Something went wrong with that request. Please try again.