From 10cbef23650ceab077caf26683b92ac45c9c0a42 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Tue, 28 Nov 2023 20:40:15 +0100 Subject: [PATCH] x --- internal/minipipeline/observation.go | 28 ++++++++-------------------- internal/minipipeline/utils.go | 2 +- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/internal/minipipeline/observation.go b/internal/minipipeline/observation.go index e824313be0..c797f3e635 100644 --- a/internal/minipipeline/observation.go +++ b/internal/minipipeline/observation.go @@ -513,30 +513,18 @@ func (c *WebObservationsContainer) controlXrefTLSFailures(resp *model.THResponse } func (c *WebObservationsContainer) controlSetHTTPFinalResponseExpectation(resp *model.THResponse) { - // Implementation note: the TH response does not have a clear semantics for "missing" values - // therefore we are accepting as valid values within the correct range - // - // also note that we add control information to all endpoints and then we check for "final" - // responses and only compare against "final" responses during the analysis for _, obs := range c.KnownTCPEndpoints { obs.ControlHTTPFailure = optional.Some(utilsStringPointerToString(resp.HTTPRequest.Failure)) - if value := resp.HTTPRequest.StatusCode; value > 0 { - obs.ControlHTTPResponseStatusCode = optional.Some(value) - } - if value := resp.HTTPRequest.BodyLength; value >= 0 { - obs.ControlHTTPResponseBodyLength = optional.Some(value) - } - controlHTTPResponseHeadersKeys := make(map[string]bool) - for key := range resp.HTTPRequest.Headers { - controlHTTPResponseHeadersKeys[key] = true - } - if len(controlHTTPResponseHeadersKeys) > 0 { - obs.ControlHTTPResponseHeadersKeys = optional.Some(controlHTTPResponseHeadersKeys) + // leave everything else nil if there was a failure, like we + // already do when processing the probe events + if resp.HTTPRequest.Failure != nil { + continue } - if v := resp.HTTPRequest.Title; v != "" { - obs.ControlHTTPResponseTitle = optional.Some(v) - } + obs.ControlHTTPResponseStatusCode = optional.Some(resp.HTTPRequest.StatusCode) + obs.ControlHTTPResponseBodyLength = optional.Some(resp.HTTPRequest.BodyLength) + obs.ControlHTTPResponseHeadersKeys = utilsExtractHTTPHeaderKeys(resp.HTTPRequest.Headers) + obs.ControlHTTPResponseTitle = optional.Some(resp.HTTPRequest.Title) } } diff --git a/internal/minipipeline/utils.go b/internal/minipipeline/utils.go index 3c9c3a379c..99be17b155 100644 --- a/internal/minipipeline/utils.go +++ b/internal/minipipeline/utils.go @@ -22,7 +22,7 @@ func utilsGeoipxLookupASN(ipAddress string) optional.Value[int64] { return optional.None[int64]() } -func utilsExtractHTTPHeaderKeys(input map[string]model.ArchivalScrubbedMaybeBinaryString) optional.Value[map[string]bool] { +func utilsExtractHTTPHeaderKeys[T ~string](input map[string]T) optional.Value[map[string]bool] { output := make(map[string]bool) for key := range input { output[key] = true