projectdiscovery/simplehttpserver

How to use http/1.1 protocol

cyal1 opened this issue · 3 comments

cyal1 commented

How to use http/1.1 protocol

@cyal1 Thanks for opening this issue. The HTTP protocol is something negotiated by the client and not enforced by the server. To force it, you should explicitly set your client to use HTTP 1.X, and, I suppose, it's also necessary to skip alpn/npn negotiation. For example, with curl, the following command performs the request with HTTP 1.1:

curl https://localhost:8000 -v --http1.1 -k
cyal1 commented

hello, I want the service only support http/1.1

net/http supports natively http/2 upgrade upon client request. I guess in this case we would need to add a CLI flag to specify explicitly which protocol to use as it needs to be set through TLSNextProto in the http server settings:

srv := &http.Server{
    Addr:         "127.0.0.1:8000",
    TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
}