Skip to content

Commit

Permalink
Merge pull request #23 from liamg/liamg-sizes
Browse files Browse the repository at this point in the history
add support for non-headered kengths
  • Loading branch information
liamg authored Feb 25, 2021
2 parents 3140c90 + 0ef9ccd commit 6a91ed8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/scan/url_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,27 @@ func (scanner *URLScanner) checkURL(job URLJob) *URLResult {

contentType := resp.Header.Get("Content-Type")

size := -1

if scanner.enableSpidering && (contentType == "" || strings.Contains(contentType, "html")) {
body, err := ioutil.ReadAll(resp.Body)
if err == nil {
for _, link := range findLinks(job.URL, body) {
scanner.queue(URLJob{URL: link})
}
}
} else {
_, _ = io.Copy(ioutil.Discard, resp.Body)
size = len(body)
}

var size int
contentLength := resp.Header.Get("Content-Length")
if contentLength != "" {
size, _ = strconv.Atoi(contentLength)
if size == -1 {
contentLength := resp.Header.Get("Content-Length")
if contentLength != "" {
size, _ = strconv.Atoi(contentLength)
} else {
cdata, _ := ioutil.ReadAll(resp.Body)
size = len(cdata)
cdata = nil
}
}

for _, length := range scanner.negativeLengths {
Expand Down

0 comments on commit 6a91ed8

Please sign in to comment.