Class: WinRM::HTTP::HttpTransport
- Inherits:
-
Object
- Object
- WinRM::HTTP::HttpTransport
- Defined in:
- lib/winrm/http/transport.rb
Overview
A generic HTTP transport that utilized HTTPClient to send messages back and forth. This backend will maintain state for every WinRMWebService instance that is instantiated so it is possible to use GSSAPI with Keep-Alive.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_RECEIVE_TIMEOUT =
Set this to an unreasonable amount because WinRM has its own timeouts
3600
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#basic_auth_only! ⇒ Object
We’ll need this to force basic authentication if desired.
-
#initialize(endpoint) ⇒ HttpTransport
constructor
A new instance of HttpTransport.
-
#no_ssl_peer_verification! ⇒ Object
Disable SSL Peer Verification.
-
#no_sspi_auth! ⇒ Object
Disable SSPI Auth.
- #receive_timeout ⇒ Object
-
#receive_timeout=(sec) ⇒ Object
HTTP Client receive timeout.
-
#send_request(message) ⇒ Object
Sends the SOAP payload to the WinRM service and returns the service’s SOAP response.
Constructor Details
#initialize(endpoint) ⇒ HttpTransport
Returns a new instance of HttpTransport.
30 31 32 33 34 35 |
# File 'lib/winrm/http/transport.rb', line 30 def initialize(endpoint) @endpoint = endpoint.is_a?(String) ? URI.parse(endpoint) : endpoint @httpcli = HTTPClient.new(agent_name: 'Ruby WinRM Client') @httpcli.receive_timeout = DEFAULT_RECEIVE_TIMEOUT @logger = Logging.logger[self] end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
28 29 30 |
# File 'lib/winrm/http/transport.rb', line 28 def endpoint @endpoint end |
Instance Method Details
#basic_auth_only! ⇒ Object
We’ll need this to force basic authentication if desired
54 55 56 57 |
# File 'lib/winrm/http/transport.rb', line 54 def basic_auth_only! auths = @httpcli.www_auth.instance_variable_get('@authenticator') auths.delete_if { |i| i.scheme !~ /basic/i } end |
#no_ssl_peer_verification! ⇒ Object
Disable SSL Peer Verification
66 67 68 |
# File 'lib/winrm/http/transport.rb', line 66 def no_ssl_peer_verification! @httpcli.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE end |
#no_sspi_auth! ⇒ Object
Disable SSPI Auth
60 61 62 63 |
# File 'lib/winrm/http/transport.rb', line 60 def no_sspi_auth! auths = @httpcli.www_auth.instance_variable_get('@authenticator') auths.delete_if { |i| i.is_a? HTTPClient::SSPINegotiateAuth } end |
#receive_timeout ⇒ Object
76 77 78 |
# File 'lib/winrm/http/transport.rb', line 76 def receive_timeout @httpcli.receive_timeout end |
#receive_timeout=(sec) ⇒ Object
HTTP Client receive timeout. How long should a remote call wait for a for a response from WinRM?
72 73 74 |
# File 'lib/winrm/http/transport.rb', line 72 def receive_timeout=(sec) @httpcli.receive_timeout = sec end |
#send_request(message) ⇒ Object
Sends the SOAP payload to the WinRM service and returns the service’s SOAP response. If an error occurrs an appropriate error is raised.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/winrm/http/transport.rb', line 42 def send_request() () hdr = { 'Content-Type' => 'application/soap+xml;charset=UTF-8', 'Content-Length' => .length } resp = @httpcli.post(@endpoint, , hdr) (resp.http_body.content) handler = WinRM::ResponseHandler.new(resp.http_body.content, resp.status) handler.parse_to_xml end |