def __init__(self, master, base): self.master = master self.windows = dict( flowlist=flowlist.FlowListBox(master), flowview=flowview.FlowView(master), commands=commands.Commands(master), keybindings=keybindings.KeyBindings(master), options=options.Options(master), help=help.HelpView(master), eventlog=eventlog.EventLog(master), edit_focus_query=grideditor.QueryEditor(master), edit_focus_cookies=grideditor.CookieEditor(master), edit_focus_setcookies=grideditor.SetCookieEditor(master), edit_focus_setcookie_attrs=grideditor.CookieAttributeEditor( master), edit_focus_multipart_form=grideditor.RequestMultipartEditor( master), edit_focus_urlencoded_form=grideditor.RequestUrlEncodedEditor( master), edit_focus_path=grideditor.PathEditor(master), edit_focus_request_headers=grideditor.RequestHeaderEditor(master), edit_focus_response_headers=grideditor.ResponseHeaderEditor( master), ) self.stack = [base] self.overlay = None
def __init__(self, master, base): self.master = master self.windows = dict( flowlist = flowlist.FlowListBox(master), flowview = flowview.FlowView(master), commands = commands.Commands(master), options = options.Options(master), help = help.HelpView(master), eventlog = eventlog.EventLog(master), edit_focus_query = grideditor.QueryEditor(master), edit_focus_cookies = grideditor.CookieEditor(master), edit_focus_setcookies = grideditor.SetCookieEditor(master), edit_focus_form = grideditor.RequestFormEditor(master), edit_focus_path = grideditor.PathEditor(master), edit_focus_request_headers = grideditor.RequestHeaderEditor(master), edit_focus_response_headers = grideditor.ResponseHeaderEditor(master), ) self.stack = [base] self.overlay = None
def edit(self, part): if self.tab_offset == TAB_REQ: message = self.flow.request else: if not self.flow.response: self.flow.response = http.HTTPResponse.make(200, b"") message = self.flow.response self.flow.backup() if message == self.flow.request and part == "c": self.master.view_grideditor( grideditor.CookieEditor(self.master, message.cookies.items(multi=True), self.set_cookies, message)) if message == self.flow.response and part == "c": self.master.view_grideditor( grideditor.SetCookieEditor(self.master, message.cookies.items(multi=True), self.set_setcookies, message)) if part == "r": # Fix an issue caused by some editors when editing a # request/response body. Many editors make it hard to save a # file without a terminating newline on the last line. When # editing message bodies, this can cause problems. For now, I # just strip the newlines off the end of the body when we return # from an editor. c = self.master.spawn_editor( message.get_content(strict=False) or b"") message.content = c.rstrip(b"\n") elif part == "f": if not message.urlencoded_form and message.raw_content: signals.status_prompt_onekey.send( prompt= "Existing body is not a URL-encoded form. Clear and edit?", keys=[ ("yes", "y"), ("no", "n"), ], callback=self.edit_form_confirm, args=(message, )) else: self.edit_form(message) elif part == "h": self.master.view_grideditor( grideditor.HeaderEditor(self.master, message.headers.fields, self.set_headers, message)) elif part == "p": p = message.path_components self.master.view_grideditor( grideditor.PathEditor(self.master, p, self.set_path_components, message)) elif part == "q": self.master.view_grideditor( grideditor.QueryEditor(self.master, message.query.items(multi=True), self.set_query, message)) elif part == "u": signals.status_prompt.send(prompt="URL", text=message.url, callback=self.set_url) elif part == "m" and message == self.flow.request: signals.status_prompt_onekey.send(prompt="Method", keys=common.METHOD_OPTIONS, callback=self.edit_method) elif part == "o": signals.status_prompt.send(prompt="Code", text=str(message.status_code), callback=self.set_resp_status_code) elif part == "m" and message == self.flow.response: signals.status_prompt.send(prompt="Message", text=message.reason, callback=self.set_resp_reason) signals.flow_change.send(self, flow=self.flow)