Closed vegerot closed 4 months ago
note: Axios (using the default node:http
adapter) does the right thing here
let axios = (await import("axios")).default
let url = "https://www-teflon.walmart.com.akadns.net"
let desiredTLSServername = "www-teflon.walmart.com"
await axios.get(url, {
headers: {
Host: desiredTLSServername
}
})
Uncaught AxiosError: Request failed with status code 444
at settle (file:///Users/m0c0j7y/gecgithub01.walmart.com/r0r039p/page-bank/node_modules/axios/lib/core/settle.js:19:12)
at IncomingMessage.handleStreamEnd (file:///Users/m0c0j7y/gecgithub01.walmart.com/r0r039p/page-bank/node_modules/axios/lib/adapters/http.js:589:11)
at IncomingMessage.emit (node:events:532:35)
at IncomingMessage.emit (node:domain:551:15)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (file:///Users/m0c0j7y/gecgithub01.walmart.com/r0r039p/page-bank/node_modules/axios/lib/core/Axios.js:45:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async REPL8:1:33
at async node:repl:645:29 {
code: 'ERR_BAD_REQUEST',
(again, we want a 444 here)
Deno behaves the same as Node, but Bun does what I want:
It looks like this behavior has changed recently
Questions for maintainer:
fetch
?fetch
that will use the Host
HTTP header as the TLS servername
?Client
and set the Client.ClientOptions.TlsOptions.host
, but that would require me to depend on undici
. I am currently happy with my project with no dependencies c:host
header isn't allowed to be set manually. Node-wise, we disallow setting the host header because of https://github.com/nodejs/undici/issues/2318.const Agent = globalThis[Symbol.for('undici.globalDispatcher.1')].constructor
globalThis[Symbol.for('undici.globalDispatcher.1')] = new Agent(...)
- Desired in what context? Spec-wise, the
host
header isn't allowed to be set manually. Node-wise, we disallow setting the host header because of Fetch failed when setting host: header correctly #2318.
Thank you. So this behavior was changed sometime between Node 20.5.1 and 20.12.1? And the two comments (#332, #764) I cited in the OP are no longer correct?
Also, specifically for the Host header, this server I'm talking about requires me to set both the TLS servername and the Host header to a specific value. How would you recommend I do this?
Also, specifically for the Host header, this server I'm talking about requires me to set both the TLS servername and the Host header to a specific value. How would you recommend I do this?
Don't use fetch
. Use undici.request
.
thanks! When I use undici.request
, it doesn't decompress the response body. What would you recommend to do this? Is there a way to set the Host
header without switching off of fetch
?
You'll need to manually decompress the body based on the headers. We have #3255 & #3274 in progress aiming for that.
Thank you @metcoder95 ! I guess it's a little disappointing because fetch
does almost what I want, but because I can't set the Host
header I need to switch to a less convenient API.
I understand you want to strictly conform to the fetch
spec, but I wish there was a special way to override the Host
behavior. I get that it doesn't make sense, though.
I'll look into those issues, and may help with the implementation 🙂
Bug Description
I have seen it mentioned in a few issues (#332, #764), that we set the TLS
servername
to the value of theHost
HTTP header. However, for me it's settingservername
to the origin of the URL.Reproducible By
Expected Behavior
Should receive HTTP 444
Actual Behavior
Logs & Screenshots
Environment
Additional context
To avoid any XY problems, let me explain what I'm trying to do.
I am trying to make a
fetch
call to https://www-teflon.walmart.com.akadns.net. However, it is configured to only accept connections with the SNI ofwww-teflon.walmart.com
. Reproduction to demonstrate:I want to do this using
fetch
in Node.js.