Class: WinRM::PSRP::MessageFragmenter
- Inherits:
-
Object
- Object
- WinRM::PSRP::MessageFragmenter
- Defined in:
- lib/winrm/psrp/message_fragmenter.rb
Overview
PowerShell Remoting Protocol message fragmenter.
Constant Summary collapse
- DEFAULT_BLOB_LENGTH =
32_768
Instance Attribute Summary collapse
-
#max_blob_length ⇒ Object
Returns the value of attribute max_blob_length.
-
#object_id ⇒ Object
readonly
Returns the value of attribute object_id.
Instance Method Summary collapse
- #fragment(message) ⇒ Object
-
#initialize(max_blob_length = DEFAULT_BLOB_LENGTH) ⇒ MessageFragmenter
constructor
A new instance of MessageFragmenter.
Constructor Details
#initialize(max_blob_length = DEFAULT_BLOB_LENGTH) ⇒ MessageFragmenter
Returns a new instance of MessageFragmenter.
24 25 26 27 |
# File 'lib/winrm/psrp/message_fragmenter.rb', line 24 def initialize(max_blob_length = DEFAULT_BLOB_LENGTH) @object_id = 0 @max_blob_length = max_blob_length || DEFAULT_BLOB_LENGTH end |
Instance Attribute Details
#max_blob_length ⇒ Object
Returns the value of attribute max_blob_length.
30 31 32 |
# File 'lib/winrm/psrp/message_fragmenter.rb', line 30 def max_blob_length @max_blob_length end |
#object_id ⇒ Object (readonly)
Returns the value of attribute object_id.
29 30 31 |
# File 'lib/winrm/psrp/message_fragmenter.rb', line 29 def object_id @object_id end |
Instance Method Details
#fragment(message) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/winrm/psrp/message_fragmenter.rb', line 32 def fragment() @object_id += 1 = .bytes bytes_fragmented = 0 fragment_id = 0 fragment = nil while bytes_fragmented < .length last_byte = bytes_fragmented + max_blob_length last_byte = .length if last_byte > .length fragment = Fragment.new( object_id, .bytes[bytes_fragmented..last_byte - 1], fragment_id, bytes_fragmented.zero?, last_byte == .length ) fragment_id += 1 bytes_fragmented = last_byte yield fragment if block_given? end fragment end |