diff --git a/src/digest/io_digest.cr b/src/digest/io_digest.cr index 06167a349870..0efcb56b7715 100644 --- a/src/digest/io_digest.cr +++ b/src/digest/io_digest.cr @@ -30,8 +30,8 @@ class IO::Digest < IO def initialize(@io : IO, @digest_algorithm : ::Digest, @mode = DigestMode::Read) end - def read(slice : Bytes) - read_bytes = io.read(slice) + def read(slice : Bytes) : Int32 + read_bytes = io.read(slice).to_i32 if @mode.read? digest_algorithm.update(slice[0, read_bytes]) end diff --git a/src/http/content.cr b/src/http/content.cr index 2c4be03cb32e..9bec0e66abda 100644 --- a/src/http/content.cr +++ b/src/http/content.cr @@ -26,7 +26,7 @@ module HTTP class FixedLengthContent < IO::Sized include Content - def read(slice : Bytes) + def read(slice : Bytes) : Int32 ensure_send_continue super end @@ -58,9 +58,9 @@ module HTTP def initialize(@io : IO) end - def read(slice : Bytes) + def read(slice : Bytes) : Int32 ensure_send_continue - @io.read(slice) + @io.read(slice).to_i32 end def read_byte : UInt8? @@ -112,7 +112,7 @@ module HTTP @received_final_chunk = false end - def read(slice : Bytes) + def read(slice : Bytes) : Int32 ensure_send_continue count = slice.size return 0 if count == 0 @@ -123,7 +123,7 @@ module HTTP to_read = Math.min(count, @chunk_remaining) - bytes_read = @io.read slice[0, to_read] + bytes_read = @io.read(slice[0, to_read]).to_i32 if bytes_read == 0 raise IO::EOFError.new("Invalid HTTP chunked content") diff --git a/src/io/argf.cr b/src/io/argf.cr index 2874e7d16dca..afa92c2a545b 100644 --- a/src/io/argf.cr +++ b/src/io/argf.cr @@ -10,7 +10,7 @@ class IO::ARGF < IO @read_from_stdin = false end - def read(slice : Bytes) + def read(slice : Bytes) : Int32 first_initialize unless @initialized if current_io = @current_io diff --git a/src/io/hexdump.cr b/src/io/hexdump.cr index b48d36ac8bfa..1ead92779cc0 100644 --- a/src/io/hexdump.cr +++ b/src/io/hexdump.cr @@ -26,8 +26,8 @@ class IO::Hexdump < IO def initialize(@io : IO, @output : IO = STDERR, @read = false, @write = false) end - def read(buf : Bytes) - @io.read(buf).tap do |read_bytes| + def read(buf : Bytes) : Int32 + @io.read(buf).to_i32.tap do |read_bytes| buf[0, read_bytes].hexdump(@output) if @read && read_bytes end end diff --git a/src/io/sized.cr b/src/io/sized.cr index 6ad0a7da1b14..ad451523fffe 100644 --- a/src/io/sized.cr +++ b/src/io/sized.cr @@ -25,11 +25,11 @@ class IO::Sized < IO @read_remaining = read_size.to_u64 end - def read(slice : Bytes) + def read(slice : Bytes) : Int32 check_open count = {slice.size.to_u64, @read_remaining}.min - bytes_read = @io.read slice[0, count] + bytes_read = @io.read(slice[0, count]).to_i32 @read_remaining -= bytes_read bytes_read end diff --git a/src/io/stapled.cr b/src/io/stapled.cr index 3fc6e2f92d7d..98d90eadb238 100644 --- a/src/io/stapled.cr +++ b/src/io/stapled.cr @@ -30,10 +30,10 @@ class IO::Stapled < IO end # Reads a slice from `reader`. - def read(slice : Bytes) + def read(slice : Bytes) : Int32 check_open - @reader.read(slice) + @reader.read(slice).to_i32 end # Gets a string from `reader`.