(method: Method, uri: Uri)
| 1323 | } |
| 1324 | |
| 1325 | async fn webkit_inspector_ui_file(method: Method, uri: Uri) -> Response { |
| 1326 | let Some(root) = webkit::webkit_inspector_ui_root() else { |
| 1327 | return AppError::not_found("WebInspectorUI resources are not available on this Mac.") |
| 1328 | .into_response(); |
| 1329 | }; |
| 1330 | if uri.path().trim_end_matches('/') == "/webkit-inspector-ui/Main.html" { |
| 1331 | if method != Method::GET && method != Method::HEAD { |
| 1332 | return StatusCode::METHOD_NOT_ALLOWED.into_response(); |
| 1333 | } |
| 1334 | let main_html = match tokio::fs::read_to_string(root.join("Main.html")).await { |
| 1335 | Ok(main_html) => main_html, |
| 1336 | Err(_) => return StatusCode::NOT_FOUND.into_response(), |
| 1337 | }; |
| 1338 | let body = if method == Method::HEAD { |
| 1339 | Body::empty() |
| 1340 | } else { |
| 1341 | Body::from(webkit::inject_frontend_host(&main_html)) |
| 1342 | }; |
| 1343 | return Response::builder() |
| 1344 | .status(StatusCode::OK) |
| 1345 | .header(header::CONTENT_TYPE, "text/html; charset=utf-8") |
| 1346 | .header( |
| 1347 | header::CACHE_CONTROL, |
| 1348 | "no-store, no-cache, must-revalidate, max-age=0", |
| 1349 | ) |
| 1350 | .header(header::PRAGMA, "no-cache") |
| 1351 | .header(header::EXPIRES, "0") |
| 1352 | .body(body) |
| 1353 | .unwrap_or_else(|_| StatusCode::INTERNAL_SERVER_ERROR.into_response()); |
| 1354 | } |
| 1355 | match static_files::serve_static_under(root, "/webkit-inspector-ui", method, uri, None).await { |
| 1356 | Ok(response) => response, |
| 1357 | Err(status) => status.into_response(), |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | fn request_origin(headers: &HeaderMap) -> Option<String> { |
| 1362 | headers |
nothing calls this directly
no test coverage detected