File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -325,21 +325,27 @@ func (scanner *URLScanner) checkURL(job URLJob) *URLResult {
325325
326326 contentType := resp .Header .Get ("Content-Type" )
327327
328+ size := - 1
329+
328330 if scanner .enableSpidering && (contentType == "" || strings .Contains (contentType , "html" )) {
329331 body , err := ioutil .ReadAll (resp .Body )
330332 if err == nil {
331333 for _ , link := range findLinks (job .URL , body ) {
332334 scanner .queue (URLJob {URL : link })
333335 }
334336 }
335- } else {
336- _ , _ = io .Copy (ioutil .Discard , resp .Body )
337+ size = len (body )
337338 }
338339
339- var size int
340- contentLength := resp .Header .Get ("Content-Length" )
341- if contentLength != "" {
342- size , _ = strconv .Atoi (contentLength )
340+ if size == - 1 {
341+ contentLength := resp .Header .Get ("Content-Length" )
342+ if contentLength != "" {
343+ size , _ = strconv .Atoi (contentLength )
344+ } else {
345+ cdata , _ := ioutil .ReadAll (resp .Body )
346+ size = len (cdata )
347+ cdata = nil
348+ }
343349 }
344350
345351 for _ , length := range scanner .negativeLengths {
You can’t perform that action at this time.
0 commit comments