Class: HTTPI::Adapter::HTTP
Overview
HTTPI::Adapter::HTTP
Adapter for the http.rb client. github.com/httprb/http.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(request) ⇒ HTTP
constructor
A new instance of HTTP.
-
#request(method) ⇒ Object
Executes arbitrary HTTP requests.
Methods inherited from Base
Constructor Details
#initialize(request) ⇒ HTTP
Returns a new instance of HTTP.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/httpi/adapter/http.rb', line 15 def initialize(request) if request.auth.digest? raise NotSupportedError, "http.rb does not support HTTP digest authentication" end if request.auth.ntlm? raise NotSupportedError, "http.rb does not support NTLM digest authentication" end @request = request @client = create_client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
27 28 29 |
# File 'lib/httpi/adapter/http.rb', line 27 def client @client end |
Instance Method Details
#request(method) ⇒ Object
Executes arbitrary HTTP requests.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/httpi/adapter/http.rb', line 31 def request(method) unless ::HTTP::Request::METHODS.include? method raise NotSupportedError, "http.rb does not support custom HTTP methods" end response = begin @client.send(method, @request.url, :body => @request.body) rescue OpenSSL::SSL::SSLError raise SSLError end Response.new(response.code, response.headers.to_h, response.body.to_s) end |