Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.1

* fix: encode the string to binary when using `String#bytesplice` (if the string is UTF-8 and the range would split multibyte characters, bytesplicing raises an error).

## 1.2.0

### Improvements
Expand Down
1 change: 0 additions & 1 deletion lib/http/2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ def receive(data)
unless @streams_recently_closed.key?(stream_id)
connection_error(:protocol_error, msg: "sent window update on idle stream")
end
stream = @streams_recently_closed[stream_id]
process_window_update(frame: frame, encode: true)
# Endpoints MUST ignore
# WINDOW_UPDATE or RST_STREAM frames received in this state (closed), though
Expand Down
11 changes: 9 additions & 2 deletions lib/http/2/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ def append_str(str, data)
def read_str(str, n)
return "".b if n == 0

enc = str.encoding

if enc != Encoding::BINARY
str = str.dup if str.frozen?
str.force_encoding(Encoding::BINARY)
end

chunk = str.byteslice(0, n)
str.bytesplice(0, chunk.length, "")
chunk
chunk.force_encoding(Encoding::BINARY)
end
else
def read_str(str, n)
Expand All @@ -37,7 +44,7 @@ def read_str(str, n)
chunk = str.byteslice(0, n)
remaining = str.byteslice(n, str.size - n)
remaining ? str.replace(remaining) : str.clear
chunk
chunk.force_encoding(Encoding::BINARY)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/http/2/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module HTTP2
VERSION = "1.2.0"
VERSION = "1.2.1"
end
Loading