1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Correctly handle resource headers + additional headers (fix a bad marge)

This commit is contained in:
François Beausoleil 2009-08-12 12:54:43 -04:00
parent 3425532660
commit 4ed5085446
2 changed files with 14 additions and 4 deletions

View file

@ -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

View file

@ -1,4 +1,10 @@
require 'rubygems'
require 'spec'
begin
require "ruby-debug"
rescue LoadError
# NOP, ignore
end
require File.dirname(__FILE__) + '/../lib/restclient'