def test_get_cookies_none(self): h = odict.ODictCaseless() resp = tutils.tresp() resp.headers = h assert not resp.get_cookies()
def test_get_content_type(self): h = odict.ODictCaseless() h["Content-Type"] = ["text/plain"] resp = tutils.tresp() resp.headers = h assert resp.headers.get_first("content-type") == "text/plain"
def tflow(): h = odict.ODictCaseless() h["test"] = ["value"] req = wsgi.Request("http", "GET", "/", h, "") return wsgi.Flow(("127.0.0.1", 8888), req)
def test_get_cookies_none(self): h = odict.ODictCaseless() r = tutils.treq() r.headers = h assert len(r.get_cookies()) == 0
def test_simple(self): ba = authentication.BasicProxyAuth(authentication.PassManNonAnon(), "test") h = odict.ODictCaseless() assert ba.auth_challenge_headers() assert not ba.authenticate(h)
def make_connect_request(address): address = Address.wrap(address) return HTTPRequest("authority", "CONNECT", None, address.host, address.port, None, (1, 1), odict.ODictCaseless(), "")
def data_out(self, data): vals = [] for i in data: vals.append([i[0], [i[1], odict.ODictCaseless(i[2])]]) return odict.ODict(vals)
def edit(self, part): if self.tab_offset == TAB_REQ: message = self.flow.request else: if not self.flow.response: self.flow.response = HTTPResponse( self.flow.request.httpversion, 200, "OK", odict.ODictCaseless(), "") self.flow.response.reply = controller.DummyReply() message = self.flow.response self.flow.backup() if message == self.flow.request and part == "c": self.master.view_grideditor( grideditor.CookieEditor(self.master, message.get_cookies().lst, self.set_cookies, message)) if message == self.flow.response and part == "c": self.master.view_grideditor( grideditor.SetCookieEditor(self.master, message.get_cookies(), self.set_setcookies, message)) if part == "r": with decoded(message): # 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.content or "") message.content = c.rstrip("\n") elif part == "f": if not message.get_form_urlencoded() and message.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.lst, self.set_headers, message)) elif part == "p": p = message.get_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.get_query().lst, self.set_query, message)) elif part == "u": signals.status_prompt.send(prompt="URL", text=message.url, callback=self.set_url) elif part == "m": 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.code), callback=self.set_resp_code) elif part == "m": signals.status_prompt.send(prompt="Message", text=message.msg, callback=self.set_resp_msg) signals.flow_change.send(self, flow=self.flow)
def set_headers(self, lst, conn): conn.headers = odict.ODictCaseless(lst) signals.flow_change.send(self, flow=self.flow)