Skip to content
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

feat: allow bodyless responses for non empty status codes #1447

Merged
merged 1 commit into from Apr 28, 2020

Conversation

ejose19
Copy link
Contributor

@ejose19 ejose19 commented Apr 20, 2020

Fixes #1446

Either "Content-Length" must be left (resulting in 0) or we need to add "Connection: close" header as well. The former is what it's in this PR, but opinions are welcomed if the later is better.

If approved will add test cases. Usage:

app.use((ctx, next) => {
  ctx.body = null; // Must be set first, as this sets status to 204 automatically
  ctx.status = 404;
});

@codecov
Copy link

codecov bot commented Apr 20, 2020

Codecov Report

Merging #1447 into master will decrease coverage by 70.24%.
The diff coverage is 60.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1447       +/-   ##
===========================================
- Coverage   99.37%   29.13%   -70.25%     
===========================================
  Files           4        4               
  Lines         479      484        +5     
  Branches      128      130        +2     
===========================================
- Hits          476      141      -335     
- Misses          0      320      +320     
- Partials        3       23       +20     
Impacted Files Coverage Δ
lib/response.js 25.15% <0.00%> (-74.21%) ⬇️
lib/application.js 60.68% <75.00%> (-37.55%) ⬇️
lib/request.js 10.49% <0.00%> (-89.51%) ⬇️
lib/context.js 28.26% <0.00%> (-71.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ddab48...3d1a042. Read the comment docs.

@dead-horse
Copy link
Member

I'm OK with this change, can you add a test case for this?

@ejose19
Copy link
Contributor Author

ejose19 commented Apr 20, 2020

@dead-horse Done, should be good now.

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

Successfully merging this pull request may close these issues.

Preserve given status when response body is null
3 participants