Skip to content

docs: correct disableTLSCerts, agent defaults, redirects and status flags - #1864

Closed
yxshee wants to merge 1 commit into
forwardemail:masterfrom
yxshee:fix/docs-tls-agent-redirect-status
Closed

yxshee wants to merge 1 commit into
forwardemail:masterfrom
yxshee:fix/docs-tls-agent-redirect-status

Conversation

@yxshee

@yxshee yxshee commented Oct 26, 2026

Copy link
Copy Markdown

I checked the docs against the current code on master and ran each claim against a local build (npm run build:lib). These are the places where the docs and the code disagree.

Changes

  1. .disableTLSCerts() sets rejectUnauthorized=false, not true. The TLS options section (and the JSDoc in src/node/index.js) said true. The code does options.rejectUnauthorized = !this._disableTLSCerts. I wrapped https.request and called request.get('https://127.0.0.1:1/').disableTLSCerts(). The captured option was false.

  2. Agents accept disableTLSCerts as a default. It is in the defaults array in src/agent-base.js but was missing from the list in "Default options for multiple requests". typeof request.agent().disableTLSCerts is 'function', and calling it records { fn: 'disableTLSCerts' } in the agent defaults.

  3. Response status flags. ResponseBase#_setStatusProperties also sets res.redirect, res.created and res.unprocessableEntity, which the list left out. Against a local server, a 201 gave created=true, a 302 gave redirect=true (with .redirects(0)), and a 422 gave unprocessableEntity=true.

  4. HEAD requests do not follow redirects by default in Node. The Node Request constructor calls this.redirects(method === 'HEAD' ? 0 : 5). A local 302 -> /end returned 200 for request.get(), but request.head() failed with status 302. Adding .redirects(5) made the HEAD request return 200. I added a sentence about this. I also changed res.redirects(n) to req.redirects(n), since it is a request method.

  5. Retry example syntax error. The example had .then(finished); followed by .catch(failed);. node --check on that snippet gives SyntaxError: Unexpected token '.'. With the semicolon removed it parses.

I made the same code-level fixes (1, 2, 3, the semicolon, and req.redirects(n)) in docs/zh_CN/index.md and docs/ko_KR/index.md. I did not add the HEAD sentence to the translations, because I did not want to write new Chinese or Korean prose.

Testing

  • npx eslint -c .eslintrc src/node/index.js passes (one existing no-unused-vars warning, unrelated).
  • make test-node: 414 passing. The only 2 failures are the IPv6 tests, which fail because my machine has no IPv6. The source change is a comment only.
  • I did not regenerate index.html, following CONTRIBUTING.

…lags

- disableTLSCerts() sets rejectUnauthorized to false, not true (docs and
  JSDoc)
- add disableTLSCerts to the list of agent default methods
- add the res.redirect, res.created and res.unprocessableEntity flags
  that Response sets
- note that HEAD requests in Node follow no redirects by default, and
  refer to req.redirects(n) instead of res.redirects(n)
- remove a stray semicolon that made the retry example a syntax error

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NQDmA3mwGfL83pbg9WQ6ey
@titanism titanism closed this in cc24a56 Nov 7, 2026
@titanism

titanism commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks, every correction checks out against the source. The commit also applies them to the Chinese and Korean HTML pages and regenerates index.html, so they show on the site. Closing in favor of the combined commit, released in v10.4.2 and now available on npm: https://github.com/forwardemail/superagent/releases/tag/v10.4.2

Consider supporting our efforts to maintain this project by using Forward Email for your email infrastructure needs at https://forwardemail.net.

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.

2 participants