Skip to content

Commit 2686c43

Browse files
Merge pull request #189 from igrigorik/frame-buffer-clear
FrameBuffer#clear
2 parents 3150890 + 2606207 commit 2686c43

6 files changed

Lines changed: 18 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.1.3
2+
3+
HTTP2::FrameBuffer#clear: clears the buffered data chunks
4+
5+
this API is useful for clients which want to react to a peer GOAWAY frame by cleaning the buffer before closing the stream
6+
17
## 1.1.2
28

39
* allow sending and receiving multiple GOAWAY frames, as per RFC 9113, section 6.8

example/server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
if options[:secure]
2626
ctx = OpenSSL::SSL::SSLContext.new
27-
ctx.cert = OpenSSL::X509::Certificate.new(File.open("keys/server.crt"))
28-
ctx.key = OpenSSL::PKey::RSA.new(File.open("keys/server.key"))
27+
ctx.cert = OpenSSL::X509::Certificate.new(File.read("keys/server.crt"))
28+
ctx.key = OpenSSL::PKey::RSA.new(File.read("keys/server.key"))
2929

3030
ctx.ssl_version = :TLSv1_2
3131
ctx.options = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]

example/upgrade_server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
if options[:secure]
2323
ctx = OpenSSL::SSL::SSLContext.new
24-
ctx.cert = OpenSSL::X509::Certificate.new(File.open("keys/server.crt"))
25-
ctx.key = OpenSSL::PKey::RSA.new(File.open("keys/server.key"))
24+
ctx.cert = OpenSSL::X509::Certificate.new(File.read("keys/server.crt"))
25+
ctx.key = OpenSSL::PKey::RSA.new(File.read("keys/server.key"))
2626
ctx.npn_protocols = [DRAFT]
2727

2828
server = OpenSSL::SSL::SSLServer.new(server, ctx)

lib/http/2/flow_buffer.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ def <<(frame)
127127
@bytesize += frame[:payload].bytesize
128128
end
129129

130+
def clear
131+
@buffer.clear
132+
@bytesize = 0
133+
end
134+
130135
def empty?
131136
@buffer.empty?
132137
end

lib/http/2/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module HTTP2
4-
VERSION = "1.1.2"
4+
VERSION = "1.1.3"
55
end

sig/frame_buffer.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module HTTP2
44

55
@buffer: Array[data_frame]
66

7+
def clear: () -> void
8+
79
def <<: (data_frame frame) -> void
810

911
def empty?: () -> bool

0 commit comments

Comments
 (0)