The server token from `Authorization: Bearer ` (or the `x-server-token` header).
(headers: &HeaderMap)
| 862 | .map(str::trim) |
| 863 | .filter(|value| !value.is_empty()) |
| 864 | .unwrap_or("http"); |
| 865 | Some(format!("{scheme}://{host}")) |
| 866 | } |
| 867 | |
| 868 | /// Rewrite a server-relative `download_url` (`/v1/mods/<id>/download`) to an absolute URL |
| 869 | /// against `base`, so clients (libcurl) get a usable URL. An already-absolute URL (a CDN |
| 870 | /// link) and `None` are left untouched, and the stored manifest stays host-portable. |
| 871 | fn absolutize_download_url(url: &mut Option<String>, base: Option<&str>) { |
| 872 | let (Some(current), Some(base)) = (url.as_deref(), base) else { |
| 873 | return; |
| 874 | }; |
| 875 | if current.is_empty() || current.contains("://") { |
| 876 | return; |
| 877 | } |
| 878 | let base = base.trim_end_matches('/'); |
| 879 | let path = if current.starts_with('/') { |
| 880 | current.to_string() |
| 881 | } else { |
| 882 | format!("/{current}") |
| 883 | }; |
| 884 | *url = Some(format!("{base}{path}")); |
| 885 | } |
| 886 | |
| 887 | fn forwarded_ips(state: &AppState, headers: &HeaderMap) -> Option<Vec<String>> { |
| 888 | let header = state.client_ip_header.as_ref()?; |
no test coverage detected