{"id":"b865c0222576dfd4","repo":"actix/actix-web","slug":"unsupported-http-version","errorCode":null,"errorMessage":"Unsupported HTTP version: {:?}.","messagePattern":"Unsupported HTTP version: (.+?)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"actix-http/src/service.rs","lineNumber":983,"sourceCode":"\n            #[cfg(not(feature = \"http2\"))]\n            Protocol::Http2 => {\n                panic!(\"HTTP/2 support is disabled (enable with the `http2` feature flag)\")\n            }\n\n            Protocol::Http1 => HttpServiceHandlerResponse {\n                state: State::H1 {\n                    dispatcher: h1::Dispatcher::new(\n                        io,\n                        Rc::clone(&self.flow),\n                        self.cfg.clone(),\n                        peer_addr,\n                        conn_data,\n                    ),\n                },\n            },\n\n            proto => unimplemented!(\"Unsupported HTTP version: {:?}.\", proto),\n        }\n    }\n}\n\n#[cfg(not(feature = \"http2\"))]\npin_project! {\n    #[project = StateProj]\n    enum State<T, S, B, X, U>\n    where\n        T: AsyncRead,\n        T: AsyncWrite,\n        T: Unpin,\n\n        S: Service<Request>,\n        S::Future: 'static,\n        S::Error: Into<Response<BoxBody>>,\n\n        B: MessageBody,","sourceCodeStart":965,"sourceCodeEnd":1001,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-http/src/service.rs#L965-L1001","documentation":"In the HTTP service handler, incoming connections are dispatched by `Protocol`. At actix-http/src/service.rs:952-984 explicit arms handle `Http1` and (when the `http2` feature is on) `Http2`; any other protocol variant hits the catch-all `proto => unimplemented!(...)`, which panics. In practice this is reached only for protocol variants the build does not support (e.g. HTTP/2 connections when the `http2` feature is disabled at runtime via a custom Protocol, or future/unknown variants).","triggerScenarios":"A connection arrives (or is injected) with a `Protocol` variant other than `Http1`/`Http2`, or HTTP/2 traffic reaches this arm while the `http2` cargo feature is compiled out (note: that specific case has its own clearer panic at line 968).","commonSituations":"Building actix-http with a restricted feature set, or a custom/integration layer that feeds an unsupported Protocol enum value into the service.","solutions":["Ensure the `http2` feature is enabled in `Cargo.toml` if you serve HTTP/2: `actix-http = { version = \"...\", features = [\"http2\"] }`.","Audit custom code/integrations that construct a `Protocol` and pass it to the service to confirm only Http1/Http2 are used.","If you genuinely need another protocol, implement a dedicated handler arm upstream rather than relying on the catch-all."],"exampleFix":"# before\n# Cargo.toml\n[dependencies]\nactix-http = \"4\"\n\n# after\n[dependencies]\nactix-http = { version = \"4\", features = [\"http2\"] }","handlingStrategy":"validation","validationCode":"// Validate the protocol before dispatch (integration code only).\n// Ensure only Http1/Http2 reach the service, and that the http2 feature is enabled.\nfn is_supported(p: actix_http::Protocol) -> bool {\n    matches!(p, actix_http::Protocol::Http1 | actix_http::Protocol::Http2)\n}\n// In Cargo.toml: actix-http = { features = [\"http2\"] }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable the `http2` feature when serving HTTP/2.","Do not feed custom/unknown Protocol variants into the HTTP service."],"tags":["rust","actix","actix-http","runtime","panic","http","http2","features"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}