More replacements for refactoring.

Minor layout adjustments.
Alignment of conffile/optiondict/cmdline parameters.
This commit is contained in:
Bernardo Damele
2010-11-08 12:36:48 +00:00
parent eb999de0f1
commit 78d7b17483
10 changed files with 41 additions and 23 deletions

View File

@@ -21,6 +21,7 @@ from lib.core.common import posixToNtSlashes
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.enums import PLACE
from lib.parse.headers import headersParser
from lib.parse.html import htmlParser
@@ -33,9 +34,9 @@ def forgeHeaders(cookie, ua):
headers = {}
for header, value in conf.httpHeaders:
if cookie and header == "Cookie":
if cookie and header == PLACE.COOKIE:
headers[header] = cookie
elif ua and header == "User-Agent":
elif ua and header == PLACE.UA:
headers[header] = ua
else:
headers[header] = value

View File

@@ -166,7 +166,7 @@ class Connect:
requestHeaders += "\n".join(["%s: %s" % (header, value) for header, value in req.header_items()])
if not req.has_header("Cookie") and cookieStr:
if not req.has_header(PLACE.COOKIE) and cookieStr:
requestHeaders += "\n%s" % cookieStr[:-2]
if not req.has_header("Connection"):
@@ -283,7 +283,7 @@ class Connect:
page = sanitizeAsciiString(page)
parseResponse(page, responseHeaders)
responseMsg += "[#%d] (%s - %d):\n" % (requestID, status, code)
responseMsg += "[#%d] (%d %s):\n" % (requestID, code, status)
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))
@@ -370,7 +370,7 @@ class Connect:
if not auxHeaders:
auxHeaders = {}
auxHeaders["Range"] = "bytes=-1"
auxHeaders[NULLCONNECTION.RANGE] = "bytes=-1"
_, headers = Connect.getPage(url=uri, get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method, auxHeaders=auxHeaders, raise404=raise404)