Object
A generic HTTP transport that utilized HTTPClient to send messages back and forth. This backend will maintain state for every WinRMWebService instance that is instatiated so it is possible to use GSSAPI with Keep-Alive.
# File lib/winrm/http/transport.rb, line 29 def initialize(endpoint) @endpoint = endpoint.is_a?(String) ? URI.parse(endpoint) : endpoint @httpcli = HTTPClient.new(:agent_name => 'Ruby WinRM Client') @httpcli.receive_timeout = 3600 # Set this to an unreasonable amount for now because WinRM has timeouts @logger = Logging.logger[self] end
We’ll need this to force basic authentication if desired
# File lib/winrm/http/transport.rb, line 53 def basic_auth_only! auths = @httpcli.www_auth.instance_variable_get('@authenticator') auths.delete_if {|i| i.scheme !~ /basic/} end
Disable SSPI Auth
# File lib/winrm/http/transport.rb, line 59 def no_sspi_auth! auths = @httpcli.www_auth.instance_variable_get('@authenticator') auths.delete_if {|i| i.is_a? HTTPClient::SSPINegotiateAuth } end
# File lib/winrm/http/transport.rb, line 36 def send_request(message) hdr = {'Content-Type' => 'application/soap+xml;charset=UTF-8', 'Content-Length' => message.length} resp = @httpcli.post(@endpoint, message, hdr) if(resp.status == 200) # Version 1.1 of WinRM adds the namespaces in the document instead of the envelope so we have to # add them ourselves here. This should have no affect version 2. doc = Nokogiri::XML(resp.http_body.content) doc.collect_namespaces.each_pair do |k,v| doc.root.add_namespace((k.split(/:/).last),v) unless doc.namespaces.has_key?(k) end return doc else raise WinRMHTTPTransportError, "Bad HTTP response returned from server (#{resp.status})." end end
Generated with the Darkfish Rdoc Generator 2.