提取响应状态码 从 SIP 响应消息的第一行提取状态码
(msg: &str)
| 384 | /// |
| 385 | /// 从 SIP 响应消息的第一行提取状态码 |
| 386 | pub fn extract_status_code(msg: &str) -> Option<u16> { |
| 387 | let first_line = msg.lines().next()?; |
| 388 | let trimmed = first_line.trim(); |
| 389 | |
| 390 | if !trimmed.starts_with("SIP/2.0") { |
| 391 | return None; |
| 392 | } |
| 393 | |
| 394 | let parts: Vec<&str> = trimmed.split_whitespace().collect(); |
| 395 | if parts.len() >= 2 { |
| 396 | parts[1].parse().ok() |
| 397 | } else { |
| 398 | None |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | /// 提取 Via 分支参数 |
| 403 | pub fn extract_via_branch(msg: &str) -> Option<String> { |
no test coverage detected