shelf
shelf copied to clipboard
how to safety close file stream
i wanna write a file download server.
as Response code as following
return Response(
200,
body: File(file.path!).openRead(),
headers: headers,
);
as u see, i send file as stream for return;
but, i has a proplem, on browser download large file , if user cancel download process, the file has never be closed!
so, how to get the socket error for close the file stream?
i saw the code in file shelf_io.dart
at line 254
return httpResponse
.addStream(response.read())
.then((_) => httpResponse.close());
this then call be stream read end, if exception has occur, the call not be execute.
and i search on google, find the HttpResonse has a done method, this method has called by any case;
so , can expose the httpResonse.done method?
@MisterChangRay – ooo...this might be a bug, honestly!
@MisterChangRay – ooo...this might be a bug, honestly!
can fixed the bug in next version?
@kevmoo
i need too, tk
I think #399 is same issue.