From e941e60b20088609ac44313b2cd7b3f0d0462e01 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 17 Jan 2013 22:44:55 +0100 Subject: [PATCH] Minor just in place update for an Issue #348 --- lib/core/option.py | 1 + lib/request/redirecthandler.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index b3844f6d5..25e40d2fa 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1597,6 +1597,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.reflectiveMechanism = True kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0} kb.requestCounter = 0 + kb.resendPostOnRedirect = None kb.responseTimes = [] kb.resumeValues = True kb.safeCharEncode = False diff --git a/lib/request/redirecthandler.py b/lib/request/redirecthandler.py index f9f1e9c1b..8641a0f81 100644 --- a/lib/request/redirecthandler.py +++ b/lib/request/redirecthandler.py @@ -47,15 +47,17 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): kb.redirectChoice = choice.upper() - if kb.redirectChoice == REDIRECTION.YES and method == HTTPMETHOD.POST: - msg = "redirect is a result of a " - msg += "POST request. Do you want to " - msg += "resend original POST data to a new " - msg += "location? [%s] " % ("Y/n" if not kb.originalPage else "y/N") - choice = readInput(msg, default=("Y" if not kb.originalPage else "N")) + if kb.redirectChoice == REDIRECTION.YES and method == HTTPMETHOD.POST and kb.resendPostOnRedirect is None: + msg = "redirect is a result of a " + msg += "POST request. Do you want to " + msg += "resend original POST data to a new " + msg += "location? [%s] " % ("Y/n" if not kb.originalPage else "y/N") + choice = readInput(msg, default=("Y" if not kb.originalPage else "N")) - if choice.upper() == 'Y': - self.redirect_request = self._redirect_request + kb.resendPostOnRedirect = choice.upper() == 'Y' + + if kb.resendPostOnRedirect: + self.redirect_request = self._redirect_request def _redirect_request(self, req, fp, code, msg, headers, newurl): newurl = newurl.replace(' ', '%20')