Skip to content

Commit 1829cd6

Browse files
committed
Yield id, content_length even if indeterminate length
Turns out this could be useful even if it's unsupported. Includes documentation.
1 parent 4f03510 commit 1829cd6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/net/ber/ber_parser.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ def read_ber_length
148148
# implemented on the including object and that it returns a Fixnum value.
149149
# Also requires #read(bytes) to work.
150150
#
151+
# Yields the object type `id` and the data `content_length` if a block is
152+
# given. This is namely to support instrumentation.
153+
#
151154
# This does not work with non-blocking I/O.
152155
def read_ber(syntax = nil)
153156
# TODO: clean this up so it works properly with partial packets coming
@@ -157,10 +160,11 @@ def read_ber(syntax = nil)
157160
id = getbyte or return nil # don't trash this value, we'll use it later
158161
content_length = read_ber_length
159162

163+
yield id, content_length if block_given?
164+
160165
if -1 == content_length
161166
raise Net::BER::BerError, "Indeterminite BER content length not implemented."
162167
else
163-
yield id, content_length if block_given?
164168
data = read(content_length)
165169
end
166170

0 commit comments

Comments
 (0)