lib/winrm/psrp/receive_response_reader.rb in winrm-2.2.3 vs lib/winrm/psrp/receive_response_reader.rb in winrm-2.3.0
- old
+ new
@@ -1,7 +1,5 @@
-# -*- encoding: utf-8 -*-
-#
# Copyright 2016 Matt Wrock <matt@mattwrock.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -39,10 +37,11 @@
messages = []
defragmenter = MessageDefragmenter.new
read_response(wsmv_message, wait_for_done_state) do |stream|
message = defragmenter.defragment(stream[:text])
next unless message
+
if block_given?
yield message
else
messages.push(message)
end
@@ -60,10 +59,11 @@
read_message(wsmv_message, true) do |message|
exit_code = find_exit_code(message)
output.exitcode = exit_code if exit_code
decoded_text = @output_decoder.decode(message)
next unless decoded_text
+
out = { stream_type(message) => decoded_text }
output << out
yield [out[:stdout], out[:stderr]] if block_given?
end
end
@@ -77,12 +77,10 @@
when WinRM::PSRP::Message::MESSAGE_TYPES[:error_record]
type = :stderr
when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_host_call]
type = :stderr if message.data.include?('WriteError')
when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_state]
- if message.parsed_data.pipeline_state == WinRM::PSRP::MessageData::PipelineState::FAILED
- type = :stderr
- end
+ type = :stderr if message.parsed_data.pipeline_state == WinRM::PSRP::MessageData::PipelineState::FAILED
end
type
end
def find_exit_code(message)