File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -496,17 +496,19 @@ def encode_content(headers, body)
496496 #
497497 def decode_content ( headers , stream :, suppress_error : false )
498498 case headers [ "content-type" ]
499- in %r{^text/event-stream}
500- lines = enum_lines ( stream )
501- parse_sse ( lines )
502- in %r{^application/json}
499+ in %r{^application/(?:vnd\. api\+ )?json}
503500 json = stream . to_a . join
504501 begin
505502 JSON . parse ( json , symbolize_names : true )
506503 rescue JSON ::ParserError => e
507504 raise e unless suppress_error
508505 json
509506 end
507+ in %r{^text/event-stream}
508+ lines = enum_lines ( stream )
509+ parse_sse ( lines )
510+ in %r{^application/(?:x-)?jsonl}
511+ enum_lines ( stream )
510512 in %r{^text/}
511513 stream . to_a . join
512514 else
@@ -615,7 +617,7 @@ def parse_sse(lines)
615617 in "event"
616618 current . merge! ( event : value )
617619 in "data"
618- ( current [ :data ] ||= String . new ) << value << "\n "
620+ ( current [ :data ] ||= String . new ) << ( value << "\n " )
619621 in "id" unless value . include? ( "\0 " )
620622 current . merge! ( id : value )
621623 in "retry" if /^\d +$/ =~ value
You can’t perform that action at this time.
0 commit comments