Minor bug fix to always show HTTP request and response when verbose is set accordingly to 4, 5 or 6 regardless of the HTTP response code (error or not)

This commit is contained in:
Bernardo Damele 2010-12-22 13:41:36 +00:00
parent 5228f336da
commit 250608660d

View File

@ -164,8 +164,6 @@ class Connect:
cookieStr += "%s; " % cookie[8:index] cookieStr += "%s; " % cookie[8:index]
conn = urllib2.urlopen(req)
if not req.has_header("Accept-Encoding"): if not req.has_header("Accept-Encoding"):
requestHeaders += "Accept-Encoding: identity\n" requestHeaders += "Accept-Encoding: identity\n"
@ -180,12 +178,14 @@ class Connect:
requestMsg += "\n%s" % requestHeaders requestMsg += "\n%s" % requestHeaders
if post: if post:
requestMsg += "\n%s" % post requestMsg += "\n\n%s" % post
requestMsg += "\n" requestMsg += "\n"
logger.log(8, requestMsg) logger.log(8, requestMsg)
conn = urllib2.urlopen(req)
if not kb.authHeader and req.has_header("Authorization"): if not kb.authHeader and req.has_header("Authorization"):
kb.authHeader = req.get_header("Authorization") kb.authHeader = req.get_header("Authorization")
@ -244,13 +244,18 @@ class Connect:
except: except:
pass pass
responseMsg = "\n%s[#%d] (%d %s):\n" % (responseMsg, threadData.lastRequestUID, code, status) responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, status)
if responseHeaders: if responseHeaders:
logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, value) for (key, value) in responseHeaders.items()]) logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, value) for (key, value) in responseHeaders.items()])
logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page)) logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page))
if conf.verbose <= 5:
responseMsg += getUnicode(logHeaders)
elif conf.verbose > 5:
responseMsg += "%s\n%s\n" % (logHeaders, page)
logger.log(7, responseMsg)
if e.code == 401: if e.code == 401:
errMsg = "not authorized, try to provide right HTTP " errMsg = "not authorized, try to provide right HTTP "
errMsg += "authentication type and valid credentials (%d)" % code errMsg += "authentication type and valid credentials (%d)" % code
@ -309,8 +314,8 @@ class Connect:
parseResponse(page, responseHeaders) parseResponse(page, responseHeaders)
responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, status) responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, status)
if responseHeaders:
logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, value) for (key, value) in responseHeaders.items()]) logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, value) for (key, value) in responseHeaders.items()])
logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page)) logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page))
if conf.verbose <= 5: if conf.verbose <= 5: