Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http server node:http does not call connect event returning 400 #16372

Open
tarik02 opened this issue Jan 13, 2025 · 0 comments
Open

Http server node:http does not call connect event returning 400 #16372

tarik02 opened this issue Jan 13, 2025 · 0 comments
Labels
bug Something isn't working confirmed bug We can reproduce this issue node:http

Comments

@tarik02
Copy link

tarik02 commented Jan 13, 2025

What version of Bun is running?

1.1.43+76800b049

What platform is your computer?

Darwin 24.0.0 arm64 arm

What steps can reproduce the bug?

Use following code to create http proxy:

import { createServer } from 'node:http';

const server = createServer();

server.on('connect', (req, socket, head) => {
    console.log('connect');
});

server.listen(5050, () => {
    console.log('listening');
});

And connect to it with curl curl -v --proxy 'http://127.0.0.1:5050' 'https://github.com'

What is the expected behavior?

Node:

$ node src/test.js
listening
connect

curl:

$ curl -v --proxy 'http://127.0.0.1:5050' 'https://github.com'
*   Trying 127.0.0.1:5050...
* Connected to 127.0.0.1 (127.0.0.1) port 5050
* CONNECT tunnel: HTTP/1.1 negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to github.com:443
> CONNECT github.com:443 HTTP/1.1
> Host: github.com:443
> User-Agent: curl/8.7.1
> Proxy-Connection: Keep-Alive
> 

What do you see instead?

Bun:

$ bun run src/test.ts
listening

curl:

curl -v --proxy 'http://127.0.0.1:5050' 'https://github.com'
*   Trying 127.0.0.1:5050...
* Connected to 127.0.0.1 (127.0.0.1) port 5050
* CONNECT tunnel: HTTP/1.1 negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to github.com:443
> CONNECT github.com:443 HTTP/1.1
> Host: github.com:443
> User-Agent: curl/8.7.1
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 400 Bad Request
< Connection: close
< 
* CONNECT tunnel failed, response 400
* Closing connection
curl: (56) CONNECT tunnel failed, response 400

Additional information

This causes the following issue: #9786

@tarik02 tarik02 added bug Something isn't working needs triage labels Jan 13, 2025
@RiskyMH RiskyMH added node:http confirmed bug We can reproduce this issue and removed needs triage labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue node:http
Projects
None yet
Development

No branches or pull requests

2 participants