class WinRM::WSMV::SendData

Subclasses base, sends additional data to WinRM

Attributes

command_id[RW]
fragment[RW]
shell_id[RW]

Public Class Methods

new(session_opts, shell_id, command_id, fragment) click to toggle source
# File lib/winrm/wsmv/send_data.rb, line 23
def initialize(session_opts, shell_id, command_id, fragment)
  @session_opts = session_opts
  @shell_id = shell_id
  @command_id = command_id
  @fragment = fragment
end

Protected Instance Methods

create_body(body) click to toggle source
# File lib/winrm/wsmv/send_data.rb, line 36
def create_body(body)
  body.tag!("#{NS_WIN_SHELL}:Send") do |cl|
    cl << Gyoku.xml(command_body)
  end
end
create_header(header) click to toggle source
# File lib/winrm/wsmv/send_data.rb, line 32
def create_header(header)
  header << Gyoku.xml(command_headers)
end

Private Instance Methods

command_body() click to toggle source
# File lib/winrm/wsmv/send_data.rb, line 44
def command_body
  {
    "#{NS_WIN_SHELL}:Stream" => encode_bytes(fragment.bytes),
    :attributes! => {
      "#{NS_WIN_SHELL}:Stream" => {
        'Name' => 'stdin',
        'CommandId' => command_id
      }
    }
  }
end
command_headers() click to toggle source
# File lib/winrm/wsmv/send_data.rb, line 56
def command_headers
  merge_headers(
    shared_headers(@session_opts),
    resource_uri_shell(RESOURCE_URI_POWERSHELL),
    action_send,
    selector_shell_id(shell_id)
  )
end