Git Product home page Git Product logo

Comments (6)

yaziciahmet avatar yaziciahmet commented on September 25, 2024

I found that http3.Server has ServeQUICConn method on it which relays the connection to the http.Handler provided. So I can just open a quic.Listener, accept connections on that listener, and relay the connection to http.Handler. But now the question is, how do I distinguish the intent of this connection? Because if this is a /stream request, I shouldn't relay it to http.Handler. And I don't see a nice way to access the headers such as :path.

from quic-go.

marten-seemann avatar marten-seemann commented on September 25, 2024

Headers are parsed into an http.Request. If you want to use a non-HTTP protocol, you can use ALPN.

from quic-go.

yaziciahmet avatar yaziciahmet commented on September 25, 2024

But I don't have access to the underlying QUIC connection in my http.Handler to open a stream do I?

from quic-go.

marten-seemann avatar marten-seemann commented on September 25, 2024

That’s what ServeQUICConn is there for. The connection will only end up in the HTTP/e package if the ALPN is h3.

from quic-go.

yaziciahmet avatar yaziciahmet commented on September 25, 2024

Here is what I tried to do:

listener, err := quic.ListenAddrEarly(":8080", tlsConfig, &quic.Config{
	EnableDatagrams: true,
	Allow0RTT:       true,
})
if err != nil {
	return err
}

go func() {
	for {
	        conn, err := listener.Accept(context.Background())
		if err != nil {
			slog.Error("Failed to accept connection", "err", err)
			continue
		}

		slog.Info("Accepted connection", "remoteAddr", conn.RemoteAddr())
	}
}()

s.h3.ServeListener(listener)

where s.h3 is a *http3.Server instance.

When I send http3 requests to the /user endpoint, sometimes http3.Server captures the request and serves it successfully, but sometimes the quic.EarlyListener captures the request in the goroutine and client is stuck. How can I make sure that http3 requests are only handled by http3.Server, and other quic connection requests are captured by the listener? Also just a note that I need both http3.Server and the quic listener process to share the same Listener instance so that they can be served on the same port.

from quic-go.

marten-seemann avatar marten-seemann commented on September 25, 2024

There seems to be some confusion about what constitutes a request. HTTP requests are sent on streams, so accepting the connection won’t have any influence on that.

from quic-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.