Skip to content

Commit a72c167

Browse files
committed
FileHandler: added catch OperationCanceledException
1 parent 9bb6a8a commit a72c167

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,11 +1494,14 @@ private async ValueTask TrackFileAsync<T>(HttpContext context, T fileId)
14941494
throw new HttpException((int)HttpStatusCode.Forbidden, FilesCommonResource.ErrorMessage_SecurityException);
14951495
}
14961496
TrackerData fileData;
1497+
1498+
var requestAborted = context.RequestAborted;
1499+
14971500
try
14981501
{
14991502
var receiveStream = context.Request.Body;
15001503
using var readStream = new StreamReader(receiveStream);
1501-
var body = await readStream.ReadToEndAsync(context.RequestAborted);
1504+
var body = await readStream.ReadToEndAsync(requestAborted);
15021505

15031506
logger.DebugDocServiceTrackBody(body);
15041507
if (string.IsNullOrEmpty(body))
@@ -1513,6 +1516,11 @@ private async ValueTask TrackFileAsync<T>(HttpContext context, T fileId)
15131516
};
15141517
fileData = JsonSerializer.Deserialize<TrackerData>(body, options);
15151518
}
1519+
catch (OperationCanceledException e)
1520+
{
1521+
logger.ErrorDocServiceTrackReadBody(e);
1522+
throw new HttpException(StatusCodes.Status499ClientClosedRequest, "Client closed the connection prematurely");
1523+
}
15161524
catch (JsonException e)
15171525
{
15181526
logger.ErrorDocServiceTrackReadBody(e);

0 commit comments

Comments
 (0)