174174--- Process a streaming response and send chunks via output.streamer.
175175--- Returns an aggregated Google-like response compatible with map_success_response().
176176local function handle_stream_response (response , http_options )
177- local reply_to : string ? = http_options .stream_reply_to
178- local topic : string ? = http_options .stream_topic
177+ local reply_to = http_options .stream_reply_to :: string ?
178+ local topic = http_options .stream_topic :: string ?
179179 local streamer = output .streamer (reply_to , topic , http_options .stream_buffer_size or 10 )
180180 if not streamer then
181181 return nil , {
@@ -190,7 +190,7 @@ local function handle_stream_response(response, http_options)
190190 local usage_metadata : any = nil
191191 local response_metadata : table = {}
192192
193- local callbacks : StreamCallbacks = {
193+ local callbacks = {
194194 on_content = function (chunk : string )
195195 full_content = full_content .. chunk
196196 streamer :buffer_content (chunk )
@@ -285,7 +285,7 @@ function client.request(method, url, http_options)
285285
286286 if response .status_code < 200 or response .status_code >= 300 then
287287 if http_options .stream and response .stream and not response .body then
288- response .body = response .stream :read ()
288+ response .body = ( response .stream :read () :: any ) :: string
289289 end
290290 local parsed_error = parse_error_response (response )
291291 return nil , parsed_error
0 commit comments