Added --code switch to match in boolean-based tests against the HTTP response code

This commit is contained in:
Bernardo Damele
2011-08-12 16:48:11 +00:00
parent e34787db99
commit 702ed73a65
9 changed files with 39 additions and 23 deletions

View File

@@ -28,7 +28,7 @@ from lib.core.settings import LOWER_RATIO_BOUND
from lib.core.settings import UPPER_RATIO_BOUND
from lib.core.threads import getCurrentThreadData
def comparison(page, headers, getRatioValue=False, pageLength=None):
def comparison(page, headers, code=None, getRatioValue=False, pageLength=None):
if page is None and pageLength is None:
return None
@@ -50,6 +50,9 @@ def comparison(page, headers, getRatioValue=False, pageLength=None):
condition = re.search(conf.regexp, rawResponse, re.I | re.M) is not None
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
if isinstance(code, int) and conf.code:
return code == conf.code
if page:
# In case of an DBMS error page return None
if kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()):