News for hackers. Stuff that matters.
Re:I Forked Httpx by dirkc on Wednesday March 25, 2026 @06:04AM (#47515357)
You would think that sending HTTP requests is a basic capability, but I've had fun in many languages doing so. Long ago (2020, or not so long ago, depending on how you look at it) I was surprised that doing an HTTP request on node using no dependencies was a little awkward:

  const response = await new Promise( (resolve, reject) => {
    const req = https.request(url, {
    }, res => {
      let body = "";
      res.on("data", data => {
        body += data;
      });
      res.on('end', () => {
        resolve(body);
      });
    });
    req.end();
  });
Re:I Forked Httpx by rzmmm on Wednesday March 25, 2026 @07:57AM (#47516161)
Web standards have rich support for incremental/chunked payloads, the original node APIs are designed around it. From this lens the Node APIs make sense.
Re:I Forked Httpx by wging on Wednesday March 25, 2026 @06:23AM (#47515477)
These days node supports the fetch API, which is much simpler. (It wasn't there in 2020, it seems to have been added around 2022-2023.)
Re:I Forked Httpx by dirkc on Wednesday March 25, 2026 @07:21AM (#47515869)
Yes, thankfully! It's amusing to read what they say about fetch on nodejs.org [1]:

> Undici is an HTTP client library that powers the fetch API in Node.js. It was written from scratch and does not rely on the built-in HTTP client in Node.js. It includes a number of features that make it a good choice for high-performance applications.

[1] - https://nodejs.org/en/learn/getting-started/fetch

Re:I Forked Httpx by Pay08 on Wednesday March 25, 2026 @10:54AM (#47518147)
Why is it amusing?
Re:I Forked Httpx by dirkc on Wednesday March 25, 2026 @01:34PM (#47520592)
I say amusing because it points out that something I (and many other people) assume to be basic clearly has a lot more nuance to it.
Re:I Forked Httpx by b450 on Wednesday March 25, 2026 @10:53AM (#47518138)
Note that node-fetch will silently ignore any overrides to "forbidden" request headers like Host, since it's designed for parity with fetch behavior in the browser. This caused a minor debugging headache for me once.
Re:I Forked Httpx by simlevesque on Wednesday March 25, 2026 @09:46AM (#47517315)
And you don't handle errors at all...
Re:I Forked Httpx by dirkc on Wednesday March 25, 2026 @05:40PM (#47523650)
Left as an exercise for the reader... ;p
Re:I Forked Httpx by niekiepriekie on Thursday March 26, 2026 @06:33AM (#47528755)
It's node. Why do errors if you can simply ignore them.