Class: Fog::XML::SAXParserConnection

Inherits:
Core::Connection
  • Object
show all
Defined in:
lib/fog/xml/sax_parser_connection.rb

Direct Known Subclasses

Connection

Instance Method Summary collapse

Instance Method Details

#request(parser, params) ⇒ Excon::Response

Makes a request using the connection using Excon

Parameters:

  • params (Hash)

Options Hash (params):

  • :body (String)

    text to be sent over a socket

  • :headers (Hash<Symbol, String>)

    The default headers to supply in a request

  • :host (String)

    The destination host“s reachable DNS name or IP, in the form of a String

  • :path (String)

    appears after “scheme://host:port/”

  • :port (Fixnum)

    The port on which to connect, to the destination host

  • :query (Hash)

    appended to the “scheme://host:port/path/” in the form of “?key=value”

  • :scheme (String)

    The protocol; “https” causes OpenSSL to be used

  • :response_block (Proc)
  • :parser (Nokogiri::XML::SAX::Document)

Returns:

  • (Excon::Response)

Raises:

  • (Excon::Errors::StubNotFound)
  • (Excon::Errors::Timeout)
  • (Excon::Errors::SocketError)


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/xml/sax_parser_connection.rb', line 23

def request(parser, params)
  reset unless @persistent

  params[:response_block] = ::Fog::XML::Response.new(parser)

  # Make request which read chunks into parser
  response = @excon.request(params)

  # Cease parsing and override response.body with parsed data
  params[:response_block].finish
  response.body = parser.response
  response
end