Copy as raw request

Issue #807

I am not entirely sure what needs to be returned in this case.
This commit is contained in:
Shadab Zafar 2016-01-13 19:21:13 +05:30
parent 34ec2d1370
commit 152e395fa4
3 changed files with 14 additions and 0 deletions

View File

@ -282,6 +282,8 @@ def export_prompt(k, flow):
copy_as_curl_command(flow) copy_as_curl_command(flow)
elif k == "p": elif k == "p":
copy_as_python_code(flow) copy_as_python_code(flow)
elif k == "r":
copy_as_raw_request(flow)
def copy_as_curl_command(flow): def copy_as_curl_command(flow):
@ -331,6 +333,16 @@ def copy_as_python_code(flow):
copy_to_clipboard_or_prompt(data) copy_to_clipboard_or_prompt(data)
def copy_as_raw_request(flow):
if flow.request.content is None or flow.request.content == CONTENT_MISSING:
signals.status_message.send(message="Request content is missing")
return
data = netlib.http.http1.assemble_request(flow.request)
copy_to_clipboard_or_prompt(data)
def copy_to_clipboard_or_prompt(data): def copy_to_clipboard_or_prompt(data):
# pyperclip calls encode('utf-8') on data to be copied without checking. # pyperclip calls encode('utf-8') on data to be copied without checking.
# if data are already encoded that way UnicodeDecodeError is thrown. # if data are already encoded that way UnicodeDecodeError is thrown.

View File

@ -262,6 +262,7 @@ class ConnectionItem(urwid.WidgetWrap):
keys = ( keys = (
("as curl command", "c"), ("as curl command", "c"),
("as python code", "p"), ("as python code", "p"),
("as raw request", "r"),
), ),
callback = common.export_prompt, callback = common.export_prompt,
args = (self.flow,) args = (self.flow,)

View File

@ -582,6 +582,7 @@ class FlowView(tabs.Tabs):
keys = ( keys = (
("as curl command", "c"), ("as curl command", "c"),
("as python code", "p"), ("as python code", "p"),
("as raw request", "r"),
), ),
callback = common.export_prompt, callback = common.export_prompt,
args = (self.flow,) args = (self.flow,)