MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / parse_origin_authority

Function parse_origin_authority

crates/openshell-server/src/http.rs:284–303  ·  view source on GitHub ↗
(scheme: &str, authority: &str)

Source from the content-addressed store, hash-verified

282}
283
284fn parse_origin_authority(scheme: &str, authority: &str) -> Option<Origin> {
285 let scheme = scheme.to_ascii_lowercase();
286 let default_port = match scheme.as_str() {
287 "http" => 80,
288 "https" => 443,
289 _ => return None,
290 };
291 let authority = authority.trim();
292 if authority.is_empty() || authority.contains('@') {
293 return None;
294 }
295
296 let (host, port) = split_host_port(authority)?;
297 let host = normalize_host(host)?;
298 Some(Origin {
299 scheme,
300 host,
301 port: port.unwrap_or(default_port),
302 })
303}
304
305fn split_host_port(authority: &str) -> Option<(&str, Option<u16>)> {
306 if let Some(rest) = authority.strip_prefix('[') {

Callers 2

request_originFunction · 0.85
parse_originFunction · 0.85

Calls 4

split_host_portFunction · 0.85
normalize_hostFunction · 0.70
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected