(self, req, fp, code, msg, headers)
| 76 | return retVal |
| 77 | |
| 78 | def http_error_302(self, req, fp, code, msg, headers): |
| 79 | start = time.time() |
| 80 | content = None |
| 81 | forceRedirect = False |
| 82 | redurl = self._get_header_redirect(headers) if not conf.ignoreRedirects else None |
| 83 | |
| 84 | try: |
| 85 | content = fp.fp.read(MAX_CONNECTION_TOTAL_SIZE) |
| 86 | fp.fp = io.BytesIO(content) |
| 87 | except _http_client.IncompleteRead as ex: |
| 88 | content = ex.partial |
| 89 | fp.fp = io.BytesIO(content) |
| 90 | except: |
| 91 | content = b"" |
| 92 | |
| 93 | content = decodePage(content, headers.get(HTTP_HEADER.CONTENT_ENCODING), headers.get(HTTP_HEADER.CONTENT_TYPE)) |
| 94 | |
| 95 | threadData = getCurrentThreadData() |
| 96 | threadData.lastRedirectMsg = (threadData.lastRequestUID, content) |
| 97 | |
| 98 | redirectMsg = "HTTP redirect " |
| 99 | redirectMsg += "[#%d] (%d %s):\r\n" % (threadData.lastRequestUID, code, getUnicode(msg)) |
| 100 | |
| 101 | if headers: |
| 102 | logHeaders = "\r\n".join("%s: %s" % (getUnicode(key.capitalize() if hasattr(key, "capitalize") else key), getUnicode(value)) for (key, value) in headers.items()) |
| 103 | else: |
| 104 | logHeaders = "" |
| 105 | |
| 106 | redirectMsg += logHeaders |
| 107 | if content: |
| 108 | redirectMsg += "\r\n\r\n%s" % getUnicode(content[:MAX_CONNECTION_READ_SIZE]) |
| 109 | |
| 110 | logHTTPTraffic(threadData.lastRequestMsg, redirectMsg, start, time.time()) |
| 111 | logger.log(CUSTOM_LOGGING.TRAFFIC_IN, redirectMsg) |
| 112 | |
| 113 | if redurl: |
| 114 | try: |
| 115 | if not _urllib.parse.urlsplit(redurl).netloc: |
| 116 | redurl = _urllib.parse.urljoin(req.get_full_url(), redurl) |
| 117 | |
| 118 | self._infinite_loop_check(req) |
| 119 | if conf.scope: |
| 120 | if not re.search(conf.scope, redurl, re.I): |
| 121 | redurl = None |
| 122 | else: |
| 123 | forceRedirect = True |
| 124 | else: |
| 125 | self._ask_redirect_choice(code, redurl, req.get_method()) |
| 126 | except ValueError: |
| 127 | redurl = None |
| 128 | result = fp |
| 129 | |
| 130 | if redurl and (kb.choices.redirect == REDIRECTION.YES or forceRedirect): |
| 131 | parseResponse(content, headers) |
| 132 | |
| 133 | req.headers[HTTP_HEADER.HOST] = getHostHeader(redurl) |
| 134 | if headers and HTTP_HEADER.SET_COOKIE in headers: |
| 135 | cookies = dict() |
nothing calls this directly
no test coverage detected