| 1407 | authHandler = HTTPSPKIAuthHandler(_) |
| 1408 | |
| 1409 | def _setHTTPExtraHeaders(): |
| 1410 | if conf.headers: |
| 1411 | debugMsg = "setting extra HTTP headers" |
| 1412 | logger.debug(debugMsg) |
| 1413 | |
| 1414 | if "\\n" in conf.headers: |
| 1415 | conf.headers = conf.headers.replace("\\r\\n", "\\n").split("\\n") |
| 1416 | else: |
| 1417 | conf.headers = conf.headers.replace("\r\n", "\n").split("\n") |
| 1418 | |
| 1419 | for headerValue in conf.headers: |
| 1420 | if not headerValue.strip(): |
| 1421 | continue |
| 1422 | |
| 1423 | if headerValue.count(':') >= 1: |
| 1424 | header, value = (_.lstrip() for _ in headerValue.split(":", 1)) |
| 1425 | |
| 1426 | if header and value: |
| 1427 | conf.httpHeaders.append((header, value)) |
| 1428 | elif headerValue.startswith('@'): |
| 1429 | checkFile(headerValue[1:]) |
| 1430 | kb.headersFile = headerValue[1:] |
| 1431 | else: |
| 1432 | errMsg = "invalid header value: %s. Valid header format is 'name:value'" % repr(headerValue).lstrip('u') |
| 1433 | raise SqlmapSyntaxException(errMsg) |
| 1434 | |
| 1435 | elif not conf.requestFile and len(conf.httpHeaders or []) < 2: |
| 1436 | if conf.encoding: |
| 1437 | conf.httpHeaders.append((HTTP_HEADER.ACCEPT_CHARSET, "%s;q=0.7,*;q=0.1" % conf.encoding)) |
| 1438 | |
| 1439 | # Invalidating any caching mechanism in between |
| 1440 | # Reference: http://stackoverflow.com/a/1383359 |
| 1441 | conf.httpHeaders.append((HTTP_HEADER.CACHE_CONTROL, "no-cache")) |
| 1442 | |
| 1443 | def _setHTTPUserAgent(): |
| 1444 | """ |