diff options
Diffstat (limited to 'ext/openssl/lib')
-rw-r--r-- | ext/openssl/lib/openssl/buffering.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb index 32e04b4896..116179d21f 100644 --- a/ext/openssl/lib/openssl/buffering.rb +++ b/ext/openssl/lib/openssl/buffering.rb @@ -99,8 +99,27 @@ module OpenSSL::Buffering end end + if "".respond_to?(:unpack1) + def unpack_byte(str) + str.unpack1("C") + end + else + def unpack_byte(str) + str.unpack("C").first + end + end + public + # call-seq: + # ssl.getbyte => 81 + # + # Get the next 8bit byte from `ssl`. Returns `nil` on EOF + def getbyte + byte = read(1) + byte && unpack_byte(byte) + end + ## # Reads _size_ bytes from the stream. If _buf_ is provided it must # reference a string which will receive the data. |