File: sax_parser_connection.rb

package info (click to toggle)
ruby-fog-xml 0.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 204 kB
  • sloc: ruby: 371; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,534 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Fog
  module XML
    class SAXParserConnection < ::Fog::Core::Connection
      # Makes a request using the connection using Excon
      #
      # @param [Hash] params
      # @option params [String] :body text to be sent over a socket
      # @option params [Hash<Symbol, String>] :headers The default headers to supply in a request
      # @option params [String] :host The destination host"s reachable DNS name or IP, in the form of a String
      # @option params [String] :path appears after "scheme://host:port/"
      # @option params [Fixnum] :port The port on which to connect, to the destination host
      # @option params [Hash]   :query appended to the "scheme://host:port/path/" in the form of "?key=value"
      # @option params [String] :scheme The protocol; "https" causes OpenSSL to be used
      # @option params [Proc] :response_block
      # @option params [Nokogiri::XML::SAX::Document] :parser
      #
      # @return [Excon::Response]
      #
      # @raise [Excon::Errors::StubNotFound]
      # @raise [Excon::Errors::Timeout]
      # @raise [Excon::Errors::SocketError]
      #
      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
    end
  end
end