Sha256: 46ed101a889a037e66cf91478459d5f2e0f5a9a9ff669c079000d3bc8479480c
Contents?: true
Size: 1.19 KB
Versions: 6
Compression:
Stored size: 1.19 KB
Contents
# -*- coding: utf-8 -*- require 'handsoap/http/drivers/abstract_driver' module Handsoap module Http module Drivers class HttpClientDriver < AbstractDriver def self.load! require 'httpclient' end def send_http_request(request) http_client = HTTPClient.new # Set credentials. The driver will negotiate the actual scheme if request.username && request.password domain = request.url.match(/^(http(s?):\/\/[^\/]+\/)/)[1] http_client.set_auth(domain, request.username, request.password) end # pack headers headers = request.headers.inject([]) do |arr, (k,v)| arr + v.map {|x| [k,x] } end response = http_client.request(request.http_method, request.url, nil, request.body, headers) response_headers = response.header.all.inject({}) do |h, (k, v)| k.downcase! if h[k].nil? h[k] = [v] else h[k] << v end h end parse_http_part(response_headers, response.content, response.status, response.contenttype) end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems