[dependencies]
axum = { version = "0.7.5", features = ["http2"] }
tokio = { version = "1.38.0", features = ["full"] }
axum-server = { version = "0.6.0", features = ["tls-rustls"] }
axum-server-dual-protocol = "0.6.0"
I also created an SSL certificate and a private key with:
curl: (35) error:0A00010B:SSL routines::wrong version number
For dual protocol version (1) I get HTTP/2 200 for HTTPS and HTTP/1.1 200 OK for HTTP when .set_upgrade(true) isn't used, and if it is used then HTTP/2 200 for HTTPS and HTTP/1.1 301 Moved Permanently + HTTP/2 200 for HTTP.
This is very closely related to #48, but I figured that this is a bug, rather than a feature request, because the server neither used HTTP/1.1 (OK) as a response nor sent an error response (HTTP/1.1 5xx). Since the first case means basically the same what #48 describes (IIUC), then the only other thing left is to send some error response (I don't know if this must be 5xx or some other one). This is also the easiest of the two, IIUC.
If neither can be implemented, then this behavior should be documented (HTTP/0.9 response).
Here is a MWA:
I also created an SSL certificate and a private key with:
Here is what I get with
curl -sSLD - --cacert cert.pem --http0.9 http://localhost:3000 | bat -Ap
:And here is what I get with
curl -sSLD - --cacert cert.pem --http0.9 https://localhost:3000 | bat -Ap
:If instead of secure server (2) I use unsecure one (3) I get (HTTP):
and (HTTPS):
For dual protocol version (1) I get
HTTP/2 200
for HTTPS andHTTP/1.1 200 OK
for HTTP when.set_upgrade(true)
isn't used, and if it is used thenHTTP/2 200
for HTTPS andHTTP/1.1 301 Moved Permanently
+HTTP/2 200
for HTTP.This is very closely related to #48, but I figured that this is a bug, rather than a feature request, because the server neither used HTTP/1.1 (OK) as a response nor sent an error response (HTTP/1.1 5xx). Since the first case means basically the same what #48 describes (IIUC), then the only other thing left is to send some error response (I don't know if this must be 5xx or some other one). This is also the easiest of the two, IIUC.
If neither can be implemented, then this behavior should be documented (HTTP/0.9 response).