Skip to content

Commit ecbf9f1

Browse files
fix: issue where json.parse errors when receiving HTTP 204 with nobody
1 parent 90678c9 commit ecbf9f1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/orb/internal/util.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ def force_charset!(content_type, text:)
655655
def decode_content(headers, stream:, suppress_error: false)
656656
case (content_type = headers["content-type"])
657657
in Orb::Internal::Util::JSON_CONTENT
658-
json = stream.to_a.join
658+
return nil if (json = stream.to_a.join).empty?
659+
659660
begin
660661
JSON.parse(json, symbolize_names: true)
661662
rescue JSON::ParserError => e
@@ -665,7 +666,11 @@ def decode_content(headers, stream:, suppress_error: false)
665666
in Orb::Internal::Util::JSONL_CONTENT
666667
lines = decode_lines(stream)
667668
chain_fused(lines) do |y|
668-
lines.each { y << JSON.parse(_1, symbolize_names: true) }
669+
lines.each do
670+
next if _1.empty?
671+
672+
y << JSON.parse(_1, symbolize_names: true)
673+
end
669674
end
670675
in %r{^text/event-stream}
671676
lines = decode_lines(stream)

0 commit comments

Comments
 (0)