mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 18:03:50 +00:00
Prevent connection lost in mitmweb when pressing Download button. (#4849)
This commit is contained in:
parent
9346002e0f
commit
0b48fdfc29
@ -80,6 +80,11 @@ export default function FlowMenu(): JSX.Element {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reference: https://stackoverflow.com/a/63627688/9921431
|
||||||
|
const openInNewTab = (url) => {
|
||||||
|
const newWindow = window.open(url, '_blank', 'noopener,noreferrer')
|
||||||
|
if (newWindow) newWindow.opener = null
|
||||||
|
}
|
||||||
|
|
||||||
function DownloadButton({flow}: { flow: Flow }) {
|
function DownloadButton({flow}: { flow: Flow }) {
|
||||||
if (flow.type !== "http")
|
if (flow.type !== "http")
|
||||||
@ -87,23 +92,23 @@ function DownloadButton({flow}: { flow: Flow }) {
|
|||||||
|
|
||||||
if (flow.request.contentLength && !flow.response?.contentLength) {
|
if (flow.request.contentLength && !flow.response?.contentLength) {
|
||||||
return <Button icon="fa-download"
|
return <Button icon="fa-download"
|
||||||
onClick={() => window.location.href = MessageUtils.getContentURL(flow, flow.request)}
|
onClick={() => openInNewTab(MessageUtils.getContentURL(flow, flow.request))}
|
||||||
>Download</Button>
|
>Download</Button>
|
||||||
}
|
}
|
||||||
if (flow.response) {
|
if (flow.response) {
|
||||||
const response = flow.response;
|
const response = flow.response;
|
||||||
if (!flow.request.contentLength && flow.response.contentLength) {
|
if (!flow.request.contentLength && flow.response.contentLength) {
|
||||||
return <Button icon="fa-download"
|
return <Button icon="fa-download"
|
||||||
onClick={() => window.location.href = MessageUtils.getContentURL(flow, response)}
|
onClick={() => openInNewTab(MessageUtils.getContentURL(flow, response))}
|
||||||
>Download</Button>
|
>Download</Button>
|
||||||
}
|
}
|
||||||
if (flow.request.contentLength && flow.response.contentLength) {
|
if (flow.request.contentLength && flow.response.contentLength) {
|
||||||
return <Dropdown text={
|
return <Dropdown text={
|
||||||
<Button icon="fa-download" onClick={() => 1}>Download▾</Button>
|
<Button icon="fa-download" onClick={() => 1}>Download▾</Button>
|
||||||
} options={{"placement": "bottom-start"}}>
|
} options={{"placement": "bottom-start"}}>
|
||||||
<MenuItem onClick={() => window.location.href = MessageUtils.getContentURL(flow, flow.request)}>Download
|
<MenuItem onClick={() => openInNewTab(MessageUtils.getContentURL(flow, flow.request))}>Download
|
||||||
request</MenuItem>
|
request</MenuItem>
|
||||||
<MenuItem onClick={() => window.location.href = MessageUtils.getContentURL(flow, response)}>Download
|
<MenuItem onClick={() => openInNewTab(MessageUtils.getContentURL(flow, response))}>Download
|
||||||
response</MenuItem>
|
response</MenuItem>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user