Skip to content

Commit 983546d

Browse files
committed
proper fix
1 parent 1a05224 commit 983546d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/core/option.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,18 +1090,20 @@ def __setHTTPUserAgent():
10901090
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
10911091

10921092
else:
1093-
debugMsg = "loading random HTTP User-Agent header(s) from "
1094-
debugMsg += "file '%s'" % paths.USER_AGENTS
1095-
logger.debug(debugMsg)
1096-
1097-
try:
1098-
kb.userAgents = getFileItems(paths.USER_AGENTS)
1099-
except IOError:
1100-
warnMsg = "unable to read HTTP User-Agent header "
1101-
warnMsg += "file '%s'" % paths.USER_AGENTS
1102-
logger.warn(warnMsg)
1093+
if not kb.userAgents:
1094+
debugMsg = "loading random HTTP User-Agent header(s) from "
1095+
debugMsg += "file '%s'" % paths.USER_AGENTS
1096+
logger.debug(debugMsg)
11031097

1104-
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, __defaultHTTPUserAgent()))
1098+
try:
1099+
kb.userAgents = getFileItems(paths.USER_AGENTS)
1100+
except IOError:
1101+
warnMsg = "unable to read HTTP User-Agent header "
1102+
warnMsg += "file '%s'" % paths.USER_AGENTS
1103+
logger.warn(warnMsg)
1104+
1105+
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, __defaultHTTPUserAgent()))
1106+
return
11051107

11061108
count = len(kb.userAgents)
11071109

0 commit comments

Comments
 (0)