Seeing the sent request headers
This would solve...
Currently there's no way for users to see the full headers that Undici sends. You can read the headers from request.headers, but some headers like connection, content-length, transfer-encoding and host are only added just before sending the request, and there's no way to actually see what was sent.
The implementation should look like...
A few options would be to update request.headers after the request was finished (Some care would be needed for stream/iterable body as the headers are only sent after the first chunk is yielded, or if no chunks were provided), although I'm not sure if this would affect retries etc. Another option would be to add a callback like onHeadersSent(headers: string), that would provide the raw headers sent. In theory, a more "user-friendly" approach would be something like onHeadersSent(headers: {key:string;value:string}[]) or maybe a Map<string, string[]>, but that would slow things down IMO, as currently the headers are essentially kept in one large string (maybe exposing util.parseHeaders as a utility function if it isn't exposed today would help).
I have also considered...
Additional context
I'm not sure how much this is needed, if at all, as I only noticed this while looking around the code and not by an actual use-case. I'm also not sure how much it would affect performance, as it would require a few changes in how the code is written (e.g. currently the method, URI and protocol are all in the same variable as the headers, when they're actually sent).
I think we might want to add some support to diagnostic channel to expose those things.