Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Nov 28, 2023
1 parent 05ca7ee commit 10cbef2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
28 changes: 8 additions & 20 deletions internal/minipipeline/observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion internal/minipipeline/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 10cbef2

Please sign in to comment.