Skip to content

Commit

Permalink
setting use_ssl property on the Net::HTTP request to fix SSL uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Nguyen authored and RISCfuture committed Dec 29, 2010
1 parent 6ed1716 commit 7b0acb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/dropbox/api.rb
Expand Up @@ -197,7 +197,10 @@ def upload(local_file, remote_path, options={})
request['authorization'] = oauth_signature.join(', ')

proxy = URI.parse(@proxy || "")
response = Net::HTTP::Proxy(proxy.host, proxy.port).new(uri.host, uri.port).request(request)
http = Net::HTTP::Proxy(proxy.host, proxy.port).new(uri.host, uri.port)
http.use_ssl = @ssl
response = http.request(request)

if response.kind_of?(Net::HTTPSuccess) then
begin
return JSON.parse(response.body).symbolize_keys_recursively.to_struct_recursively
Expand Down
6 changes: 3 additions & 3 deletions spec/dropbox/api_spec.rb
Expand Up @@ -30,7 +30,7 @@ def stub_for_upload_testing
@response.stub!(:kind_of?).with(Net::HTTPSuccess).and_return(true)
@response.stub!(:body).and_return('{"test":"val"}')

@http = mock('Net::HTTP', :request => @response)
@http = mock('Net::HTTP', :request => @response, :use_ssl= => nil)
Net::HTTP.stub!(:new).and_return(@http)
end

Expand Down Expand Up @@ -643,7 +643,7 @@ def response_acts_as(subclass)

it "should send the request" do
uri = URI.parse(Dropbox::ALTERNATE_HOSTS['files'])
@http = mock('Net::HTTP', :request => @response)
@http = mock('Net::HTTP', :request => @response, :use_ssl= => nil)
Net::HTTP.stub!(:new).and_return(@http)

@session.upload __FILE__, 'test'
Expand All @@ -654,7 +654,7 @@ def response_acts_as(subclass)
@session.authorize

uri = URI.parse(Dropbox::ALTERNATE_SSL_HOSTS['files'])
@http = mock('Net::HTTP', :request => @response)
@http = mock('Net::HTTP', :request => @response, :use_ssl= => nil)
Net::HTTP.stub!(:new).and_return(@http)

@session.upload __FILE__, 'test'
Expand Down

0 comments on commit 7b0acb2

Please sign in to comment.