Closed JhinDeng closed 5 years ago
I’m on a business trip but this is a duplicate. This issue is understood but the problem is that changing this behavior is a major server version (breaking)
@fl0w Thanks for the reply, if the official support is the best.
So the thing here is that once you change status, Koa doesn't overwrite it. It only sets status if missing or if you're using ctx.(throw|assert)
. This isn't a bug - but rather a side effect and perhaps a docs issue. Once you understand how Koa reasons about this, it shouldn't be a problem.
ok, I've got it. thanks.
I found some code in the test case and added a line to describe the problem I encountered.
the reason is https://github.com/koajs/koa/blob/master/lib/response.js/#L83-L92 https://github.com/koajs/koa/blob/master/lib/response.js/#L134-L145
This problem may be good to avoid, but if you don't pay attention, it will cause troublesome problems. So I posted the problem I encountered here and it might help others save some time.