File tree 1 file changed +12
-6
lines changed 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 {
325
325
326
326
contentType := resp .Header .Get ("Content-Type" )
327
327
328
+ size := - 1
329
+
328
330
if scanner .enableSpidering && (contentType == "" || strings .Contains (contentType , "html" )) {
329
331
body , err := ioutil .ReadAll (resp .Body )
330
332
if err == nil {
331
333
for _ , link := range findLinks (job .URL , body ) {
332
334
scanner .queue (URLJob {URL : link })
333
335
}
334
336
}
335
- } else {
336
- _ , _ = io .Copy (ioutil .Discard , resp .Body )
337
+ size = len (body )
337
338
}
338
339
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
+ }
343
349
}
344
350
345
351
for _ , length := range scanner .negativeLengths {
You can’t perform that action at this time.
0 commit comments