Skip to content

Commit 05148d0

Browse files
committed
Fix statistics #inspect for Body::Chunked and Body::Fixed.
1 parent 0b7b481 commit 05148d0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/async/http/body/chunked.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class Chunked < Readable
2727
def initialize(protocol)
2828
@protocol = protocol
2929
@finished = false
30+
31+
@bytesize = 0
32+
@count = 0
3033
end
3134

3235
def empty?
@@ -49,11 +52,14 @@ def read
4952
chunk = @protocol.stream.read(size)
5053
@protocol.read_line # Consume the trailing CRLF
5154

55+
@bytesize += size
56+
@count += 1
57+
5258
return chunk
5359
end
5460

5561
def inspect
56-
"\#<#{self.class} #{@protocol.version}>"
62+
"\#<#{self.class} #{@bytesize} bytes read in #{@count} chunks>"
5763
end
5864
end
5965
end

lib/async/http/body/fixed.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def join
5353
end
5454

5555
def inspect
56-
"\#<#{self.class} #{protocol.version} length=#{@length} remaining=#{@remaining}>"
56+
"\#<#{self.class} length=#{@length} remaining=#{@remaining}>"
5757
end
5858
end
5959

@@ -75,7 +75,7 @@ def join
7575
end
7676

7777
def inspect
78-
"\#<#{self.class} #{protocol.version} #{@stream.closed? ? 'closed' : 'open'}>"
78+
"\#<#{self.class} #{@stream.closed? ? 'closed' : 'open'}>"
7979
end
8080
end
8181
end

0 commit comments

Comments
 (0)