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

Support CONNECT method #3862

Open
ianzone opened this issue Jan 27, 2025 · 10 comments
Open

Support CONNECT method #3862

ianzone opened this issue Jan 27, 2025 · 10 comments
Labels
enhancement New feature or request.

Comments

@ianzone
Copy link

ianzone commented Jan 27, 2025

What is the feature you are proposing?

I'm trying to build an MITM proxy using Hono, but Hono misses the CONNECT method, which the MITM proxy requires.

@ianzone ianzone added the enhancement New feature or request. label Jan 27, 2025
@EdamAme-x
Copy link
Contributor

You can use app.on

@ianzone
Copy link
Author

ianzone commented Jan 29, 2025

You can use app.on

It doesn't work. Considering code

import { Hono } from 'hono';

const app = new Hono();

app.on('CONNECT', '*', async (c) => {
  console.log('HTTP CONNECT:', c.req.method, c.req.url);
});

export default {
  port: 8080,
  fetch: app.fetch,
};

Set export http_proxy=http://127.0.0.1:8080
Then try curl -v https://github.com, you will get 400 bad request, and the console doesn't log.

@EdamAme-x
Copy link
Contributor

Sorry, please try to rewrite to lower case

@ianzone
Copy link
Author

ianzone commented Jan 29, 2025

Sorry, please try to rewrite to lower case

same result

@EdamAme-x
Copy link
Contributor

Hmm

@EdamAme-x
Copy link
Contributor

Can you intercept request? (Use app.all)

@ianzone
Copy link
Author

ianzone commented Jan 29, 2025

Can you intercept request? (Use app.all)

That's my first attempt.

@EdamAme-x
Copy link
Contributor

EdamAme-x commented Jan 29, 2025

If so, I don't think it is possible to do that with Hono.
This is true for other libraries as well.

@ianzone
Copy link
Author

ianzone commented Jan 29, 2025

That's why it's a feature request.

@yusukebe
Copy link
Member

Hi @ianzone

I'm not so familiar with MITM proxy, but supporting the CONNECT method is out of Hono's score. Hono is built with just Web Standard API, but it does not support the CONNECT method. This is the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

3 participants