Skip to content

Commit 47c8d20

Browse files
authored
Merge pull request #21 from Splat/partybranch
adding the fast lookup for if the redirect chain exists
2 parents 0465279 + 587114c commit 47c8d20

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/verify/http.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ type HTTPResult struct {
1414
Location string
1515
Server string
1616
RedirectChain []string
17+
HasRedirect bool
1718
// TODO: For fast lookup downstream
18-
// TODO: HasRedirect bool
1919
// TODO: Remediated bool // validate last redirect == Verification.Domain
2020
}
2121

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

@@ -90,5 +91,10 @@ func fetchHTTP(ctx context.Context, https bool, domain string, cfg Config) HTTPR
9091
res.StatusCode = resp.StatusCode
9192
res.Location = resp.Header.Get("Location")
9293
res.Server = resp.Header.Get("Server")
94+
95+
if len(res.RedirectChain) > 0 {
96+
res.HasRedirect = true
97+
}
98+
9399
return res
94100
}

0 commit comments

Comments
 (0)