class SOAP::HTTPStreamHandler
Constants
- Client
- MAX_RETRY_COUNT
- RETRYABLE
Attributes
client[R]
wiredump_file_base[RW]
Public Class Methods
new(options)
click to toggle source
Calls superclass method
# File lib/soap/streamHandler.rb, line 83 def initialize(options) super() @client = Client.new(nil, "SOAP4R/#{ Version }") @wiredump_file_base = nil @charset = @wiredump_dev = nil @options = options set_options @client.debug_dev = @wiredump_dev @cookie_store = nil @accept_encoding_gzip = false end
Public Instance Methods
accept_encoding_gzip=(allow)
click to toggle source
# File lib/soap/streamHandler.rb, line 99 def accept_encoding_gzip=(allow) @accept_encoding_gzip = allow end
inspect()
click to toggle source
# File lib/soap/streamHandler.rb, line 103 def inspect "#<#{self.class}>" end
reset(endpoint_url = nil)
click to toggle source
# File lib/soap/streamHandler.rb, line 112 def reset(endpoint_url = nil) if endpoint_url.nil? @client.reset_all else @client.reset(endpoint_url) end @client.save_cookie_store if @cookie_store end
send(endpoint_url, conn_data, soapaction = nil, charset = @charset)
click to toggle source
# File lib/soap/streamHandler.rb, line 107 def send(endpoint_url, conn_data, soapaction = nil, charset = @charset) conn_data.soapaction ||= soapaction # for backward conpatibility send_post(endpoint_url, conn_data, charset) end
test_loopback_response()
click to toggle source
# File lib/soap/streamHandler.rb, line 95 def test_loopback_response @client.test_loopback_response end
Private Instance Methods
decode_gzip(instring)
click to toggle source
# File lib/soap/streamHandler.rb, line 215 def decode_gzip(instring) unless send_accept_encoding_gzip? raise HTTPStreamError.new("Gzipped response content.") end begin gz = Zlib::GzipReader.new(StringIO.new(instring)) gz.read ensure gz.close end end
send_accept_encoding_gzip?()
click to toggle source
# File lib/soap/streamHandler.rb, line 211 def send_accept_encoding_gzip? @accept_encoding_gzip and defined?(::Zlib) end
send_post(endpoint_url, conn_data, charset)
click to toggle source
# File lib/soap/streamHandler.rb, line 151 def send_post(endpoint_url, conn_data, charset) conn_data.send_contenttype ||= StreamHandler.create_media_type(charset) if @wiredump_file_base filename = @wiredump_file_base + '_request.xml' f = File.open(filename, "w") f << conn_data.send_string f.close end extra = {} extra['Content-Type'] = conn_data.send_contenttype extra['SOAPAction'] = "\"#{ conn_data.soapaction }\"" extra['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip? send_string = conn_data.send_string @wiredump_dev << "Wire dump:\n\n" if @wiredump_dev begin retry_count = 0 while true res = @client.post(endpoint_url, send_string, extra) if RETRYABLE and HTTP::Status.redirect?(res.status) retry_count += 1 if retry_count >= MAX_RETRY_COUNT raise HTTPStreamError.new("redirect count exceeded") end endpoint_url = res.header["location"][0] puts "redirected to #{endpoint_url}" if $DEBUG else break end end rescue @client.reset(endpoint_url) raise end @wiredump_dev << "\n\n" if @wiredump_dev receive_string = res.content if @wiredump_file_base filename = @wiredump_file_base + '_response.xml' f = File.open(filename, "w") f << receive_string f.close end case res.status when 405 raise PostUnavailableError.new("#{ res.status }: #{ res.reason }") when 200, 500 # Nothing to do. else raise HTTPStreamError.new("#{ res.status }: #{ res.reason }") end if res.respond_to?(:header) and !res.header['content-encoding'].empty? and res.header['content-encoding'][0].downcase == 'gzip' receive_string = decode_gzip(receive_string) end conn_data.receive_string = receive_string conn_data.receive_contenttype = res.contenttype conn_data end
set_options()
click to toggle source
# File lib/soap/streamHandler.rb, line 123 def set_options HTTPConfigLoader.set_options(@client, @options) @charset = @options["charset"] || XSD::Charset.xml_encoding_label @options.add_hook("charset") do |key, value| @charset = value end @wiredump_dev = @options["wiredump_dev"] @options.add_hook("wiredump_dev") do |key, value| @wiredump_dev = value @client.debug_dev = @wiredump_dev end set_cookie_store_file(@options["cookie_store_file"]) @options.add_hook("cookie_store_file") do |key, value| set_cookie_store_file(value) end ssl_config = @options["ssl_config"] basic_auth = @options["basic_auth"] @options.lock(true) ssl_config.unlock basic_auth.unlock end