Also, it's maintained by the Node Core team, HTTP team, and in fact, most of us think that HTTP.request is almost unfixable and therefore that's what we are working on instead. At the beginning, it started from support for HTTP 1.1 only, then we also recently added HTTP 2.0 support, and now it's... You know, the Undici name might not be the best reference anymore. Anyway, so... Also, we have HTTP 1.1. It also has HTTP 1.1 pipelining support. So... It also... Something that is a little bit... There are some things that are different in it, so you might experience a few errors that you might need to deal with, essentially. So, why? Well, the problem is the HTTP, HTTP modules are a mess, okay? Mostly because they use the same API structure for both the client and the server of HTTP 1.0, and both of them are tied with the connection management with the public API. So, how can you see it? Well, you have a request.socket, okay? The fact that you have a request.socket property will tell you that there is this kind of connection, because if your system is not being on socket anymore, like on HTTP 2.0, how would you implement that? And this is the reason why you cannot support both HTTP 1.1 and HTTP 2.0 on the same API.
Finally, last but not least, we cannot change those classes without breaking express. So, yeah, well, that's the situation. So, we created undici.request to be as fast as possible, because making HTTP request should not be the bottleneck of your app. It also provides a good enough DX, a very good DX, from my point of view. It's highly configurable, it uses Node.js stream, supports HTTP 1.1 pipeline. It's great. Just use this. This is probably the code that you want to be using, okay? Undici Fetch is built to be spec compliant, okay? So, it's not putting performance as the top priority. It's spec compliance that it is. And right now, 88% of the WPT tests that we are running for Fetch, we are passing them. So, I think it's pretty good compatibility overall. However, internally, it uses WhatWGstream, so you can use Pipe2, WhatWGstream, all the things, the Redible stream, like the browser. So, all the code that uses Undici Fetch and Fetch Node could be isomorphic. Again, the protocol handling and the API are completely split, so all the things that we are going to talk about, Undici and connection management and so on, all apply to both. And this is the reason why Undici Fetch was built on top of Undici. The Fetching Node was built on top of Undici. It also supports HTTP2, HTTP pipelining, because of this separation.
Okay, let's talk about performance, because this is the critical stuff for it, okay? So, which, you know, it's the numbers are really significant here, okay? Like, Undici is pretty much unconstrained, okay? You can use, on this testing system, you can actually use Undici, one of the lowest level APIs, which is Undici.Dispatch, but to be honest, this is not what you should be using, okay? It's the underlining bit, or Undici.Stream, which is, you know, even faster, but again, probably too low a level.
Comments