diff options
| author | Christian Cleberg <[email protected]> | 2026-04-03 17:14:00 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-03 17:14:00 -0500 |
| commit | 2c38b5edee339e5fe9060a835d9772a71606dc85 (patch) | |
| tree | edc223bd3782b638c0b3d3575b6013ea4a5a4425 /DomainDig/DomainViewModel.swift | |
| parent | 8465ef359f88ddef7cad68a0c2e361bb0bfe58ff (diff) | |
| download | domain-dig-1.6.0.tar.gz domain-dig-1.6.0.tar.bz2 domain-dig-1.6.0.zip | |
Add HTTP header grading and protocol metadatav1.6.0
Diffstat (limited to 'DomainDig/DomainViewModel.swift')
| -rw-r--r-- | DomainDig/DomainViewModel.swift | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/DomainDig/DomainViewModel.swift b/DomainDig/DomainViewModel.swift index 16eaabd..0edd371 100644 --- a/DomainDig/DomainViewModel.swift +++ b/DomainDig/DomainViewModel.swift @@ -20,6 +20,11 @@ final class DomainViewModel { // HTTP Headers var httpHeaders: [HTTPHeader] = [] + var httpSecurityGrade: String? + var httpStatusCode: Int? + var httpResponseTimeMs: Int? + var httpProtocol: String? + var http3Advertised = false var httpHeadersLoading = false var httpHeadersError: String? @@ -168,6 +173,11 @@ final class DomainViewModel { hstsPreloaded = nil hstsLoading = false httpHeaders = [] + httpSecurityGrade = nil + httpStatusCode = nil + httpResponseTimeMs = nil + httpProtocol = nil + http3Advertised = false httpHeadersError = nil httpHeadersLoading = false reachabilityResults = [] @@ -210,6 +220,11 @@ final class DomainViewModel { hstsPreloaded = nil hstsLoading = true httpHeaders = [] + httpSecurityGrade = nil + httpStatusCode = nil + httpResponseTimeMs = nil + httpProtocol = nil + http3Advertised = false httpHeadersError = nil httpHeadersLoading = true reachabilityResults = [] @@ -300,8 +315,13 @@ final class DomainViewModel { private func runHTTPHeaders(domain: String) async { do { - let headers = try await HTTPHeadersService.fetch(domain: domain) - httpHeaders = headers + let result = try await HTTPHeadersService.fetch(domain: domain) + httpHeaders = result.headers + httpSecurityGrade = HTTPSecurityGrade.grade(for: result.headers).rawValue + httpStatusCode = result.statusCode + httpResponseTimeMs = result.responseTimeMs + httpProtocol = result.httpProtocol + http3Advertised = result.http3Advertised } catch { httpHeadersError = error.localizedDescription } @@ -381,6 +401,11 @@ final class DomainViewModel { sslError: sslError, hstsPreloaded: hstsPreloaded, httpHeaders: httpHeaders, + httpSecurityGrade: httpSecurityGrade, + httpStatusCode: httpStatusCode, + httpResponseTimeMs: httpResponseTimeMs, + httpProtocol: httpProtocol, + http3Advertised: http3Advertised, httpHeadersError: httpHeadersError, reachabilityResults: reachabilityResults, ipGeolocation: ipGeolocation, @@ -400,6 +425,11 @@ final class DomainViewModel { sslError: String? = nil, hstsPreloaded: Bool? = nil, httpHeaders: [HTTPHeader], + httpSecurityGrade: String? = nil, + httpStatusCode: Int? = nil, + httpResponseTimeMs: Int? = nil, + httpProtocol: String? = nil, + http3Advertised: Bool = false, httpHeadersError: String? = nil, reachabilityResults: [PortReachability], ipGeolocation: IPGeolocation?, @@ -548,6 +578,21 @@ final class DomainViewModel { for header in httpHeaders { lines.append(" \(header.name): \(header.value)") } + if let httpSecurityGrade { + lines.append("Grade: \(httpSecurityGrade)") + } + if let httpStatusCode { + lines.append("Status: \(httpStatusCode)") + } + if let httpResponseTimeMs { + lines.append("Response Time: \(httpResponseTimeMs)ms") + } + if let httpProtocol { + lines.append("Protocol: \(httpProtocol)") + } + if http3Advertised { + lines.append("HTTP/3 Advertised: Yes") + } } else if let error = httpHeadersError { lines.append("") lines.append("HTTP Headers") |
