Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/verify/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ type HTTPResult struct {
Location string
Server string
RedirectChain []string
HasRedirect bool
// TODO: For fast lookup downstream
// TODO: HasRedirect bool
// TODO: Remediated bool // validate last redirect == Verification.Domain
}

// generateHTTPResult initializes an HTTPResult struct with attempted flag set to true and an empty RedirectChain.
// The URL field is set to the target domain after extracting it from the provided domain string.
// should probably be an init method on the HTTPResult type
// generateHTTPResult initializes an HTTPResult struct with attempted
// flag set to true and an empty RedirectChain. The URL field is set
// to the target domain after extracting it from the provided domain
// string. TODO: Should probably be an init method on the HTTPResult type
func generateHTTPResult(https bool, domain string) HTTPResult {
res := HTTPResult{Attempted: true, RedirectChain: []string{}}
res := HTTPResult{Attempted: true, RedirectChain: []string{}, HasRedirect: false}
target := getTargetDomain(https, domain)
res.URL = target

Expand Down Expand Up @@ -90,5 +91,10 @@ func fetchHTTP(ctx context.Context, https bool, domain string, cfg Config) HTTPR
res.StatusCode = resp.StatusCode
res.Location = resp.Header.Get("Location")
res.Server = resp.Header.Get("Server")

if len(res.RedirectChain) > 0 {
res.HasRedirect = true
}

return res
}
Loading