Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(response): enforce status 200-599 and null-body status rules#1865

Open
nthbotast wants to merge 1 commit intonode-fetch:mainfrom
nthbotast:fix/response-status-range-1685
Open

fix(response): enforce status 200-599 and null-body status rules#1865
nthbotast wants to merge 1 commit intonode-fetch:mainfrom
nthbotast:fix/response-status-range-1685

Conversation

@nthbotast
Copy link

Summary

  • validate Response constructor status values and throw RangeError for anything outside [200, 599]
  • throw TypeError when a body is provided for null-body statuses (101, 103, 204, 205, 304)
  • keep Response.error() behavior intact by constructing then setting internal error status
  • add targeted tests for the new constructor validation cases

Validation

  • npm test -- test/response.js
  • npx xo src/response.js test/response.js

Closes #1685.

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.

When initializing a response it should throw if status is not in the range 200 to 599

1 participant