From 4ed50854461974be1544e1b7e23ac76573a3a186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beausoleil?= Date: Wed, 12 Aug 2009 12:54:43 -0400 Subject: [PATCH] Correctly handle resource headers + additional headers (fix a bad marge) --- lib/restclient/resource.rb | 12 ++++++++---- spec/base.rb | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/restclient/resource.rb b/lib/restclient/resource.rb index 9eade2c..1456eb4 100644 --- a/lib/restclient/resource.rb +++ b/lib/restclient/resource.rb @@ -46,33 +46,37 @@ module RestClient end def get(additional_headers={}, &b) + headers = (options[:headers] || {}).merge(additional_headers) Request.execute(options.merge( :method => :get, :url => url, - :headers => additional_headers), &b) + :headers => headers), &b) end def post(payload, additional_headers={}, &b) + headers = (options[:headers] || {}).merge(additional_headers) Request.execute(options.merge( :method => :post, :url => url, :payload => payload, - :headers => additional_headers), &b) + :headers => headers), &b) end def put(payload, additional_headers={}, &b) + headers = (options[:headers] || {}).merge(additional_headers) Request.execute(options.merge( :method => :put, :url => url, :payload => payload, - :headers => additional_headers), &b) + :headers => headers), &b) end def delete(additional_headers={}, &b) + headers = (options[:headers] || {}).merge(additional_headers) Request.execute(options.merge( :method => :delete, :url => url, - :headers => additional_headers), &b) + :headers => headers), &b) end def to_s diff --git a/spec/base.rb b/spec/base.rb index c27e8a4..2a1211e 100644 --- a/spec/base.rb +++ b/spec/base.rb @@ -1,4 +1,10 @@ require 'rubygems' require 'spec' +begin + require "ruby-debug" +rescue LoadError + # NOP, ignore +end + require File.dirname(__FILE__) + '/../lib/restclient'