Skip to content

Commit

Permalink
fix menu issue #51
Browse files Browse the repository at this point in the history
  • Loading branch information
barakt11 committed Jun 7, 2020
1 parent e3d18b9 commit 8fffc73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions authorization/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
sys.path.append("..")

from helpers.http import getCookieFromMessage, isStatusCodesReturned, makeMessage, makeRequest, getResponseContentLength, IHttpRequestResponseImplementation
from helpers.http import get_cookie_from_message, isStatusCodesReturned, makeMessage, makeRequest, getResponseContentLength, IHttpRequestResponseImplementation
from gui.table import LogEntry, UpdateTableEDT
from javax.swing import SwingUtilities
from java.net import URL
Expand All @@ -24,12 +24,12 @@ def tool_needs_to_be_ignored(self, toolFlag):
return False

def handle_cookies_feature(self, messageInfo):
cookies = getCookieFromMessage(self, messageInfo)
cookies = get_cookie_from_message(self, messageInfo)
if cookies:
self.lastCookies = cookies
self.fetchButton.setEnabled(True)

def isToolValid(self, toolFlag):
def valid_tool(self, toolFlag):
return (toolFlag == self._callbacks.TOOL_PROXY or
(toolFlag == self._callbacks.TOOL_REPEATER and
self.interceptRequestsfromRepeater.isSelected()))
Expand Down Expand Up @@ -110,7 +110,7 @@ def handle_message(self, toolFlag, messageIsRequest, messageInfo):

handle_cookies_feature(self, messageInfo)

if self.intercept and isToolValid(self, toolFlag):
if self.intercept and valid_tool(self, toolFlag):
handle_304_status_code_prevention(self, messageIsRequest, messageInfo)

if not messageIsRequest:
Expand All @@ -127,7 +127,7 @@ def handle_message(self, toolFlag, messageIsRequest, messageInfo):
if message_passed_interception_filters(self, messageInfo):
checkAuthorization(self, messageInfo,self._helpers.analyzeResponse(messageInfo.getResponse()).getHeaders(),self.doUnauthorizedRequest.isSelected())

def sendRequestToAutorizeWork(self, messageInfo):
def send_request_to_autorize(self, messageInfo):
if messageInfo.getResponse() is None:
message = makeMessage(self, messageInfo,False,False)
requestResponse = makeRequest(self, messageInfo, message)
Expand Down
7 changes: 5 additions & 2 deletions gui/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from javax.swing import JMenuItem
from java.awt.event import ActionListener

from authorization.authorization import send_request_to_autorize
from helpers.http import get_cookie_from_message

from thread import start_new_thread

class MenuImpl(IContextMenuFactory):
Expand Down Expand Up @@ -36,7 +39,7 @@ def __init__(self, extender, messageInfo, menuName):

def actionPerformed(self, e):
if self._menuName == "request":
start_new_thread(self._extender.sendRequestToAutorizeWork,(self._messageInfo,))
start_new_thread(send_request_to_autorize, (self._extender, self._messageInfo,))

if self._menuName == "cookie":
self._extender.replaceString.setText(self._extender.getCookieFromMessage(self._messageInfo))
self._extender.replaceString.setText(get_cookie_from_message(self._extender, self._messageInfo))
2 changes: 1 addition & 1 deletion helpers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def getResponseBody(self, requestResponse):
def getResponseContentLength(self, response):
return len(response) - self._helpers.analyzeResponse(response).getBodyOffset()

def getCookieFromMessage(self, messageInfo):
def get_cookie_from_message(self, messageInfo):
headers = list(self._helpers.analyzeRequest(messageInfo.getRequest()).getHeaders())
for header in headers:
if header.strip().lower().startswith("cookie:"):
Expand Down

0 comments on commit 8fffc73

Please sign in to comment.