{"record":{"id":"a2d073dbeca4a1d9","repo":"jdx/mise","slug":"got-non-html-text-from","errorCode":null,"errorMessage":"Got non-HTML text from {}","messagePattern":"Got non-HTML text from (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/http.rs","lineNumber":804,"sourceCode":"        }\n    }\n\n    pub(crate) async fn get_html<U: IntoUrl>(&self, url: U) -> Result<String> {\n        let url = url.into_url()?;\n        let resp = self.get_async(url.clone()).await?;\n        let is_html = resp\n            .headers()\n            .get(CONTENT_TYPE)\n            .and_then(|content_type| content_type.to_str().ok())\n            .is_some_and(|content_type| {\n                content_type\n                    .split_once(';')\n                    .map_or(content_type, |(media_type, _)| media_type)\n                    .trim()\n                    .eq_ignore_ascii_case(\"text/html\")\n            });\n        if !is_html {\n            bail!(\"Got non-HTML text from {}\", url);\n        }\n        let html = resp.text().await?;\n        Ok(html)\n    }\n\n    pub(crate) async fn json_headers<T, U: IntoUrl>(&self, url: U) -> Result<(T, HeaderMap)>\n    where\n        T: serde::de::DeserializeOwned,\n    {\n        let url = url.into_url()?;\n        let resp = self.get_async(url).await?;\n        let headers = resp.headers().clone();\n        let json = resp.json().await?;\n        Ok((json, headers))\n    }\n\n    pub(crate) async fn json_headers_with_headers<T, U: IntoUrl>(\n        &self,","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/http.rs#L786-L822","documentation":"get_html fetches a URL expecting an HTML document and validates the response's Content-Type. If the media type isn't text/html, it bails with 'Got non-HTML text from {url}' because the caller expected markup (usually for scraping docs/listings) and got JSON, plain text, or binary instead.","triggerScenarios":"Calling get_html (src/http.rs:~790) on a URL whose server responds with a non-text/html Content-Type, e.g. an API endpoint returning application/json or a redirect landing on a raw file.","commonSituations":"Scraping a page whose URL now serves JSON (site/API change); hitting a mirror or CDN that returns a different content type; pointing an HTML scrape at an API endpoint by mistake.","solutions":["Confirm the URL returns HTML in a browser or `curl -I` (Content-Type should be text/html) and correct the URL if it points at an API or raw file.","If the server sends a nonstandard Content-Type for HTML, fetch with get_text/get_async instead and parse manually.","Check for redirects that land on a different content type; use the final canonical URL."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"ct=$(curl -fsSI \"$url\" | grep -i '^content-type:')\ncase \"$ct\" in *text/html*) echo ok ;; *) echo \"non-HTML: $ct\" ;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point HTML scrapers at canonical page URLs, not API endpoints","Check final redirect targets for their content type","Prefer official JSON APIs when the source offers them"],"tags":["http","content-type","html"],"backgroundTag":"unexpected-response-shape","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}