lib/curb-fu/request/base.rb in curb-fu-0.4.3 vs lib/curb-fu/request/base.rb in curb-fu-0.4.4
- old
+ new
@@ -54,11 +54,18 @@
fields = create_post_fields(params)
fields = [fields] if fields.is_a?(String)
curb = self.build(url)
curb.http_post(*fields)
- CurbFu::Response::Base.from_curb_response(curb)
+ response = CurbFu::Response::Base.from_curb_response(curb)
+ if CurbFu.debug?
+ puts "Response from server was"
+ puts "Status: #{response.status}"
+ puts "Headers: #{response.headers.inspect}"
+ puts "Body: #{response.body.inspect}"
+ end
+ response
end
def post_file(url, params = {}, filez = {})
fields = create_post_fields(params)
fields += create_file_fields(filez)
@@ -71,9 +78,17 @@
rescue Curl::Err::InvalidPostFieldError => e
field_list = (params.merge(filez)).inject([]) { |list, (name, value)| list << "#{name} => #{value.to_s[0..49].inspect}"; list }
raise e, "There was an attempt to post invalid fields. The fields were:\n#{field_list.join("\n")}"
end
CurbFu::Response::Base.from_curb_response(curb)
+ response = CurbFu::Response::Base.from_curb_response(curb)
+ if CurbFu.debug?
+ puts "Response from server was"
+ puts "Status: #{response.status}"
+ puts "Headers: #{response.headers.inspect}"
+ puts "Body: #{response.body.inspect}"
+ end
+ response
end
def delete(url)
curb = self.build(url)
curb.http_delete
\ No newline at end of file