Пример #1
0
    def read_response_headers(self):
        self.response_arrived.wait()

        status_code = int(self.response_headers.get(':status', 502))
        headers = self.response_headers.copy()
        headers.clear(":status")

        return models.HTTPResponse(
            http_version=b"HTTP/2.0",
            status_code=status_code,
            reason='',
            headers=headers,
            content=None,
            timestamp_start=self.timestamp_start,
            timestamp_end=self.timestamp_end,
        )
Пример #2
0
    def read_response_headers(self):
        self.response_arrived.wait()

        if self.zombie:  # pragma: no cover
            raise exceptions.Http2ProtocolException("Zombie Stream")

        status_code = int(self.response_headers.get(':status', 502))
        headers = self.response_headers.copy()
        headers.clear(":status")

        return models.HTTPResponse(
            http_version=b"HTTP/2.0",
            status_code=status_code,
            reason='',
            headers=headers,
            content=None,
            timestamp_start=self.timestamp_start,
            timestamp_end=self.timestamp_end,
        )
Пример #3
0
    def edit(self, part):
        if self.tab_offset == TAB_REQ:
            message = self.flow.request
        else:
            if not self.flow.response:
                self.flow.response = models.HTTPResponse(
                    self.flow.request.http_version, 200, "OK", Headers(), "")
                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.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":
            with models.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.urlencoded_form 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.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)