Parent

Files

WinRM::HTTP::HttpTransport

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.

Attributes

endpoint[R]

Public Class Methods

new(endpoint) click to toggle source
# 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

Public Instance Methods

basic_auth_only!() click to toggle source

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
no_sspi_auth!() click to toggle source

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
send_request(message) click to toggle source
# 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.