# File lib/soap/streamHandler.rb, line 139 139: def self.create(options) 140: new(options) 141: end
# File lib/soap/streamHandler.rb, line 143 143: def initialize(options) 144: super() 145: @client = Client.new(nil, "SOAP4R/#{ Version }") 146: if @client.respond_to?(:request_filter) 147: @client.request_filter << HttpPostRequestFilter.new(@filterchain) 148: end 149: @wiredump_file_base = nil 150: @charset = @wiredump_dev = nil 151: @options = options 152: set_options 153: @client.debug_dev = @wiredump_dev 154: @cookie_store = nil 155: @accept_encoding_gzip = false 156: end
# File lib/soap/streamHandler.rb, line 162 162: def accept_encoding_gzip=(allow) 163: @accept_encoding_gzip = allow 164: end
# File lib/soap/streamHandler.rb, line 166 166: def inspect 167: "#<#{self.class}>" 168: end
# File lib/soap/streamHandler.rb, line 177 177: def reset(url = nil) 178: if url.nil? 179: @client.reset_all 180: else 181: @client.reset(url) 182: end 183: @client.save_cookie_store if @cookie_store 184: end
# File lib/soap/streamHandler.rb, line 170 170: def send(url, conn_data, soapaction = nil, charset = @charset) 171: conn_data.soapaction ||= soapaction # for backward conpatibility 172: conn_data = send_post(url, conn_data, charset) 173: @client.save_cookie_store if @cookie_store 174: conn_data 175: end
# File lib/soap/streamHandler.rb, line 288 288: def decode_gzip(instring) 289: unless send_accept_encoding_gzip? 290: raise HTTPStreamError.new("Gzipped response content.") 291: end 292: begin 293: gz = Zlib::GzipReader.new(StringIO.new(instring)) 294: gz.read 295: ensure 296: gz.close 297: end 298: end
# File lib/soap/streamHandler.rb, line 284 284: def send_accept_encoding_gzip? 285: @accept_encoding_gzip and defined?(::Zlib) 286: end
# File lib/soap/streamHandler.rb, line 219 219: def send_post(url, conn_data, charset) 220: conn_data.send_contenttype ||= StreamHandler.create_media_type(charset) 221: 222: if @wiredump_file_base 223: filename = @wiredump_file_base + '_request.xml' 224: f = File.open(filename, "w") 225: f << conn_data.send_string 226: f.close 227: end 228: 229: extheader = {} 230: extheader['Content-Type'] = conn_data.send_contenttype 231: extheader['SOAPAction'] = "\"#{ conn_data.soapaction }\"" 232: extheader['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip? 233: send_string = conn_data.send_string 234: @wiredump_dev << "Wire dump:\n\n" if @wiredump_dev 235: begin 236: retry_count = 0 237: while true 238: res = @client.post(url, send_string, extheader) 239: if RETRYABLE and HTTP::Status.redirect?(res.status) 240: retry_count += 1 241: if retry_count >= MAX_RETRY_COUNT 242: raise HTTPStreamError.new("redirect count exceeded") 243: end 244: url = res.header["location"][0] 245: puts "redirected to #{url}" if $DEBUG 246: else 247: break 248: end 249: end 250: rescue 251: @client.reset(url) 252: raise 253: end 254: @wiredump_dev << "\n\n" if @wiredump_dev 255: receive_string = res.content 256: if @wiredump_file_base 257: filename = @wiredump_file_base + '_response.xml' 258: f = File.open(filename, "w") 259: f << receive_string 260: f.close 261: end 262: case res.status 263: when 405 264: raise PostUnavailableError.new("#{ res.status }: #{ res.reason }") 265: when 200, 202, 500 266: # Nothing to do. 202 is for oneway service. 267: else 268: raise HTTPStreamError.new("#{ res.status }: #{ res.reason }") 269: end 270: 271: # decode gzipped content, if we know it's there from the headers 272: if res.respond_to?(:header) and !res.header['content-encoding'].empty? and 273: res.header['content-encoding'][0].downcase == 'gzip' 274: receive_string = decode_gzip(receive_string) 275: # otherwise check for the gzip header 276: elsif @accept_encoding_gzip && receive_string[0..1] == "\x1f\x8b" 277: receive_string = decode_gzip(receive_string) 278: end 279: conn_data.receive_string = receive_string 280: conn_data.receive_contenttype = res.contenttype 281: conn_data 282: end
# File lib/soap/streamHandler.rb, line 188 188: def set_options 189: @options["http"] ||= ::SOAP::Property.new 190: HTTPConfigLoader.set_options(@client, @options["http"]) 191: @charset = @options["http.charset"] || XSD::Charset.xml_encoding_label 192: @options.add_hook("http.charset") do |key, value| 193: @charset = value 194: end 195: @wiredump_dev = @options["http.wiredump_dev"] 196: @options.add_hook("http.wiredump_dev") do |key, value| 197: @wiredump_dev = value 198: @client.debug_dev = @wiredump_dev 199: end 200: set_cookie_store_file(@options["http.cookie_store_file"]) 201: @options.add_hook("http.cookie_store_file") do |key, value| 202: set_cookie_store_file(value) 203: end 204: ssl_config = @options["http.ssl_config"] 205: basic_auth = @options["http.basic_auth"] 206: auth = @options["http.auth"] 207: @options["http"].lock(true) 208: ssl_config.unlock 209: basic_auth.unlock 210: auth.unlock 211: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.