Skip to content

v5.0.0

Latest

Choose a tag to compare

@github-actions github-actions released this 25 Nov 16:19
Immutable release. Only release title and notes can be modified.
5834281

Upgrading from 4.x

  • Node.js and modules. Use Node.js 22.19.0 or later. urllib now ships a single ES module. Use import { request } from 'urllib' in ESM or await import('urllib') inside an async CommonJS function. #722 · #904 · #820
  • HTTP/2 by default. With undici 8, HTTPS requests negotiate HTTP/2 when the server supports it. To force HTTP/1.1, pass { allowH2: false } to request() or HttpClient. If you supply an undici Pool or Client as the dispatcher, set the option when you construct it. #820
  • Timeout handling. If you inspect err.cause.code for HTTP/2 response-header timeouts, update your check from UND_ERR_INFO to UND_ERR_HEADERS_TIMEOUT. #820
  • TypeScript. The declarations now use type-fest 6, which requires TypeScript 6 or later with strict enabled. RequestOptions.signal now accepts AbortSignal | EventEmitter. #995 · #820

Redirects and query strings

  • When urllib follows a 303 See Other, it changes any method other than GET or HEAD to GET and drops the body and content headers. If the target needs a retry, urllib retries only the target. A failed redirect after a POST upload no longer resends the upload. #1000
  • For GET and HEAD, urllib appends request data to the query string before the URL fragment. For example, adding { page: 2 } to /search?q=node#top sends /search?q=node&page=2 to the server. #1000

API and diagnostics

  • Import getCookies, getSetCookies, setCookie, deleteCookie, parseCookie, and the Cookie type directly from urllib. #742
  • res.timing.dnslookup reports milliseconds from the start of the request until DNS lookup completes. It is 0 on a reused socket. getDispatcherPoolStats() combines HTTP/1.1 and HTTP/2 counters for each origin. #743 · #820
  • The exported RequestOptions type now includes rejectUnauthorized for top-level request() and curl(). For an HttpClient instance, configure connect.rejectUnauthorized. #919

Security fixes also available in 4.x. Version 4.9.1 stopped forwarding credentials on cross-origin redirects. Version 4.9.2 added escaping for multipart filenames and field names. Both fixes are included in 5.0.0. v4.9.1 · v4.9.2

First-time contributor. @dependabot[bot] contributed #631.

Full changelog since v4.9.0