Skip to content

Response content with 204 response code #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
YaLehin opened this issue May 14, 2020 · 5 comments · Fixed by #762
Closed

Response content with 204 response code #760

YaLehin opened this issue May 14, 2020 · 5 comments · Fixed by #762

Comments

@YaLehin
Copy link

YaLehin commented May 14, 2020

Description

As I could understand from the code the JsonApiWriter tries to write a response content to the response with StatusCode 204, that causes the exception:

System.InvalidOperationException: Writing to the response body is invalid for responses with status code 204.
  at at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ThrowWritingToResponseBodyNotSupported() 
@bart-degreed
Copy link
Contributor

bart-degreed commented May 14, 2020 via email

@YaLehin
Copy link
Author

YaLehin commented May 14, 2020

I use the alpha5 version of JADNC. This occurs when on delete request. The request like this (Method=DELETE) http://localhost:5000/api/v1/item/3
After successful deletion, the response is forming with a status code of 204 and at JsonApiWriter.cs is an attempt to write response content
{"links":{"self":"http://localhost:5000/api/v1/item/3"},"data":null}
This leads to that exception.
I found this exception only running under the debugger. No crashes at normal running.
Maybe it is a planned situation, I am quite new to JADNC and all dot net ecosystem and trying to get acquainted with it.

@bart-degreed
Copy link
Contributor

Hi @YaLehin, thanks for the details. I can see this exception in the Kestrel console. Can you test if my PR fixes this for you?

@YaLehin
Copy link
Author

YaLehin commented May 15, 2020

Thank you, I'll test and will report here the result.

@YaLehin
Copy link
Author

YaLehin commented May 20, 2020

Hi @bart-degreed,
I have tested your PR. All works fine, there is no exception now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants