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

refactor: remove ServerResponse.headersSent support check #77

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
==================

* remove `ServerResponse.headersSent` support check
* remove unnecessary devDependency `safe-buffer`
* remove `unpipe` package and use native `unpipe()` method
* remove unnecessary devDependency `readable-stream`
Expand Down
18 changes: 2 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function finalhandler (req, res, options) {
var status

// ignore 404 on in-flight response
if (!err && headersSent(res)) {
if (!err && res.headersSent) {
debug('cannot 404 after headers sent')
return
}
Expand Down Expand Up @@ -122,7 +122,7 @@ function finalhandler (req, res, options) {
}

// cannot actually respond
if (headersSent(res)) {
if (res.headersSent) {
debug('cannot %d after headers sent', status)
if (req.socket) {
req.socket.destroy()
Expand Down Expand Up @@ -245,20 +245,6 @@ function getResponseStatusCode (res) {
return status
}

/**
* Determine if the response headers have been sent.
*
* @param {object} res
* @returns {boolean}
* @private
*/

function headersSent (res) {
return typeof res.headersSent !== 'boolean'
? Boolean(res._header)
: res.headersSent
}

/**
* Send response.
*
Expand Down
Loading