Skip to content

Wrong error logging when a client cancels the request #8696

@maxcherednik

Description

@maxcherednik

Describe the bug

When a client cancels the web request(closing a browser for instance) the request is cancelled with a help of the CancelationToken. Everything works fine but this log line is written into the log file:

2019-03-19T08:37:13.093+00:00 [17] ERR Microsoft.AspNetCore.Server.HttpSys.HttpSysListener [/main] - ResponseStream::Dispose; Fewer bytes were written than were specified in the Content-Length.

The reason is this line in the ResponseBody class: https://github.com/aspnet/AspNetCore/blob/5f4be179e3bf6d88a53667935fc5c4bd2d71988c/src/Servers/HttpSys/src/RequestProcessing/ResponseBody.cs#L131

This line is executed when a server calls Dispose on the ResponseBody instance and in general it is good have this check. But now it should have a distinction between the normal flow and the flow when a client is not connected anymore.

To Reproduce

--

Expected behavior

There should not be an error log like this:

2019-03-19T08:37:13.093+00:00 [17] ERR Microsoft.AspNetCore.Server.HttpSys.HttpSysListener [/main] - ResponseStream::Dispose; Fewer bytes were written than were specified in the Content-Length.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-httpsyshelp wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions