Class: Handsoap::Http::Drivers::CurbDriver
- Inherits:
-
AbstractDriver
- Object
- AbstractDriver
- Handsoap::Http::Drivers::CurbDriver
- Defined in:
- lib/handsoap/http/drivers/curb_driver.rb
Instance Attribute Summary collapse
-
#enable_cookies ⇒ Object
Returns the value of attribute enable_cookies.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CurbDriver
constructor
A new instance of CurbDriver.
- #send_http_request(request) ⇒ Object
Methods inherited from AbstractDriver
#parse_headers, #parse_http_part, #parse_multipart, #parse_multipart_boundary
Constructor Details
#initialize ⇒ CurbDriver
Returns a new instance of CurbDriver.
10 11 12 |
# File 'lib/handsoap/http/drivers/curb_driver.rb', line 10 def initialize @enable_cookies = false end |
Instance Attribute Details
#enable_cookies ⇒ Object
Returns the value of attribute enable_cookies.
8 9 10 |
# File 'lib/handsoap/http/drivers/curb_driver.rb', line 8 def @enable_cookies end |
Class Method Details
.load! ⇒ Object
14 15 16 |
# File 'lib/handsoap/http/drivers/curb_driver.rb', line 14 def self.load! require 'curb' end |
Instance Method Details
#send_http_request(request) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/handsoap/http/drivers/curb_driver.rb', line 36 def send_http_request(request) http_client = get_curl(request.url) # Set credentials. The driver will negotiate the actual scheme if request.username && request.password http_client.userpwd = [request.username, ":", request.password].join end # pack headers headers = request.headers.inject([]) do |arr, (k,v)| arr + v.map {|x| "#{k}: #{x}" } end http_client.headers = headers # I don't think put/delete is actually supported .. case request.http_method when :get http_client.http_get when :post http_client.http_post(request.body) when :put http_client.http_put(request.body) when :delete http_client.http_delete else raise "Unsupported request method #{request.http_method}" end parse_http_part(http_client.header_str.gsub(/^HTTP.*\r\n/, ""), http_client.body_str, http_client.response_code, http_client.content_type) end |