mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 11:03:13 +00:00
added hints from mhils
This commit is contained in:
parent
ab322f0be4
commit
adfdcc9391
@ -345,24 +345,6 @@ class FlowContentView(RequestHandler):
|
|||||||
def get(self, flow_id, message, content_view):
|
def get(self, flow_id, message, content_view):
|
||||||
message = getattr(self.flow, message)
|
message = getattr(self.flow, message)
|
||||||
|
|
||||||
original_cd = message.headers.get("Content-Disposition", None)
|
|
||||||
filename = None
|
|
||||||
if original_cd:
|
|
||||||
filename = re.search("filename=([\w\" \.\-\(\)]+)", original_cd)
|
|
||||||
if filename:
|
|
||||||
filename = filename.group(1)
|
|
||||||
if not filename:
|
|
||||||
filename = self.flow.request.path.split("?")[0].split("/")[-1]
|
|
||||||
|
|
||||||
filename = re.sub(r"[^\w\" \.\-\(\)]", "", filename)
|
|
||||||
cd = "attachment; filename={}".format(filename)
|
|
||||||
self.set_header("Content-Disposition", cd)
|
|
||||||
self.set_header("Content-Type", "application/json")
|
|
||||||
self.set_header("X-Content-Type-Options", "nosniff")
|
|
||||||
self.set_header("X-Frame-Options", "DENY")
|
|
||||||
|
|
||||||
self.set_header("Content-Encoding", "")
|
|
||||||
|
|
||||||
description, lines, error = contentviews.get_message_content_view(
|
description, lines, error = contentviews.get_message_content_view(
|
||||||
contentviews.get(content_view.replace('_', ' ')), message
|
contentviews.get(content_view.replace('_', ' ')), message
|
||||||
)
|
)
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -14,7 +14,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
section {
|
section {
|
||||||
padding: 5px 12px;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.first-line {
|
.first-line {
|
||||||
@ -40,26 +42,21 @@
|
|||||||
margin: 0 0 5px;
|
margin: 0 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
article {
|
||||||
|
|
||||||
.flowview-container{
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flowview-body{
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 5px 12px 0;
|
padding: 5px 12px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flowview-footer{
|
footer {
|
||||||
box-shadow: 0 0 3px gray;
|
box-shadow: 0 0 3px gray;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
height:23px;
|
height:23px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.inline-input {
|
.inline-input {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin: 0 -3px;
|
margin: 0 -3px;
|
||||||
|
@ -37,6 +37,7 @@ class ViewServer extends Component {
|
|||||||
componentWillMount(){
|
componentWillMount(){
|
||||||
this.setContentView(this.props)
|
this.setContentView(this.props)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps){
|
componentWillReceiveProps(nextProps){
|
||||||
this.setContentView(nextProps)
|
this.setContentView(nextProps)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ ShowFullContentButton.propTypes = {
|
|||||||
function ShowFullContentButton ( {setShowFullContent, showFullContent} ){
|
function ShowFullContentButton ( {setShowFullContent, showFullContent} ){
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!showFullContent && <Button className="view-all-content-btn" isXs={true} onClick={() => setShowFullContent(true)} text="Show full content"/>
|
!showFullContent && <Button className="view-all-content-btn btn-xs" onClick={() => setShowFullContent(true)} text="Show full content"/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ import React, { PropTypes, Component } from 'react'
|
|||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import * as ContentViews from './ContentViews'
|
import * as ContentViews from './ContentViews'
|
||||||
import { setContentView, setContentViewSelectorOpen } from "../../ducks/ui/flow";
|
import { setContentView } from "../../ducks/ui/flow";
|
||||||
|
|
||||||
|
|
||||||
function ViewItem({ name, setContentView, children }) {
|
function ViewItem({ name, setContentView, children }) {
|
||||||
return (
|
return (
|
||||||
@ -29,24 +28,25 @@ class ViewSelector extends Component {
|
|||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
super(props, context)
|
super(props, context)
|
||||||
this.close = this.close.bind(this)
|
this.close = this.close.bind(this)
|
||||||
|
this.state = {open: false}
|
||||||
}
|
}
|
||||||
close() {
|
close() {
|
||||||
this.props.setContentViewSelectorOpen(false)
|
this.setState({open: false})
|
||||||
document.removeEventListener('click', this.close)
|
document.removeEventListener('click', this.close)
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropdown(e){
|
onDropdown(e){
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.props.setContentViewSelectorOpen(!this.props.isContentViewSelectorOpen)
|
this.setState({open: !this.state.open})
|
||||||
document.addEventListener('click', this.close)
|
document.addEventListener('click', this.close)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {contentViews, activeView, isEdit, isContentViewSelectorOpen, setContentViewSelectorOpen, setContentView} = this.props
|
const {contentViews, activeView, isEdit, setContentView} = this.props
|
||||||
let edit = ContentViews.Edit.displayName
|
let edit = ContentViews.Edit.displayName
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classnames('dropup pull-left', { open: isContentViewSelectorOpen })}>
|
<div className={classnames('dropup pull-left', { open: this.state.open })}>
|
||||||
<a className="btn btn-default btn-xs"
|
<a className="btn btn-default btn-xs"
|
||||||
onClick={ e => this.onDropdown(e) }
|
onClick={ e => this.onDropdown(e) }
|
||||||
href="#">
|
href="#">
|
||||||
@ -74,9 +74,7 @@ export default connect (
|
|||||||
contentViews: state.settings.contentViews,
|
contentViews: state.settings.contentViews,
|
||||||
activeView: state.ui.flow.contentView,
|
activeView: state.ui.flow.contentView,
|
||||||
isEdit: !!state.ui.flow.modifiedFlow,
|
isEdit: !!state.ui.flow.modifiedFlow,
|
||||||
isContentViewSelectorOpen: state.ui.flow.isContentViewSelectorOpen
|
|
||||||
}), {
|
}), {
|
||||||
setContentView,
|
setContentView,
|
||||||
setContentViewSelectorOpen
|
|
||||||
}
|
}
|
||||||
)(ViewSelector)
|
)(ViewSelector)
|
||||||
|
@ -84,8 +84,8 @@ export class Request extends Component {
|
|||||||
const { flow, isEdit, updateFlow, uploadContent } = this.props
|
const { flow, isEdit, updateFlow, uploadContent } = this.props
|
||||||
let noContent = !isEdit && (flow.request.contentLength == 0 || flow.request.contentLength == null)
|
let noContent = !isEdit && (flow.request.contentLength == 0 || flow.request.contentLength == null)
|
||||||
return (
|
return (
|
||||||
<section className="request flowview-container">
|
<section className="request">
|
||||||
<div className="flowview-body">
|
<article>
|
||||||
<ToggleEdit/>
|
<ToggleEdit/>
|
||||||
<RequestLine
|
<RequestLine
|
||||||
flow={flow}
|
flow={flow}
|
||||||
@ -103,14 +103,16 @@ export class Request extends Component {
|
|||||||
flow={flow}
|
flow={flow}
|
||||||
onContentChange={content => updateFlow({ request: {content}})}
|
onContentChange={content => updateFlow({ request: {content}})}
|
||||||
message={flow.request}/>
|
message={flow.request}/>
|
||||||
</div>
|
</article>
|
||||||
<div hidden={noContent} className="flowview-footer">
|
{!noContent &&
|
||||||
|
<footer>
|
||||||
<ContentViewOptions
|
<ContentViewOptions
|
||||||
flow={flow}
|
flow={flow}
|
||||||
readonly={!isEdit}
|
readonly={!isEdit}
|
||||||
message={flow.request}
|
message={flow.request}
|
||||||
uploadContent={content => uploadContent(flow, content, "request")}/>
|
uploadContent={content => uploadContent(flow, content, "request")}/>
|
||||||
</div>
|
</footer>
|
||||||
|
}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -149,8 +151,8 @@ export class Response extends Component {
|
|||||||
let noContent = !isEdit && (flow.response.contentLength == 0 || flow.response.contentLength == null)
|
let noContent = !isEdit && (flow.response.contentLength == 0 || flow.response.contentLength == null)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="response flowview-container">
|
<section className="response">
|
||||||
<div className="flowview-body">
|
<article>
|
||||||
<ToggleEdit/>
|
<ToggleEdit/>
|
||||||
<ResponseLine
|
<ResponseLine
|
||||||
flow={flow}
|
flow={flow}
|
||||||
@ -168,14 +170,16 @@ export class Response extends Component {
|
|||||||
onContentChange={content => updateFlow({ response: {content}})}
|
onContentChange={content => updateFlow({ response: {content}})}
|
||||||
message={flow.response}
|
message={flow.response}
|
||||||
/>
|
/>
|
||||||
</div>
|
</article>
|
||||||
<div hidden={noContent} className="flowview-footer">
|
{!noContent &&
|
||||||
|
<footer >
|
||||||
<ContentViewOptions
|
<ContentViewOptions
|
||||||
flow={flow}
|
flow={flow}
|
||||||
message={flow.response}
|
message={flow.response}
|
||||||
uploadContent={content => uploadContent(flow, content, "response")}
|
uploadContent={content => uploadContent(flow, content, "response")}
|
||||||
readonly={!isEdit}/>
|
readonly={!isEdit}/>
|
||||||
</div>
|
</footer>
|
||||||
|
}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ Button.propTypes = {
|
|||||||
icon: PropTypes.string
|
icon: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Button({ onClick, text, icon, disabled, isXs, className }) {
|
export default function Button({ onClick, text, icon, disabled, className }) {
|
||||||
return (
|
return (
|
||||||
<div className={classnames(className, 'btn btn-default', { 'btn-xs': isXs})}
|
<div className={classnames(className, 'btn btn-default')}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
disabled={disabled}>
|
disabled={disabled}>
|
||||||
{icon && (<i className={"fa fa-fw " + icon}/> )}
|
{icon && (<i className={"fa fa-fw " + icon}/> )}
|
||||||
|
@ -10,15 +10,13 @@ export const SET_CONTENT_VIEW = 'UI_FLOWVIEW_SET_CONTENT_VIEW',
|
|||||||
UPDATE_EDIT = 'UI_FLOWVIEW_UPDATE_EDIT',
|
UPDATE_EDIT = 'UI_FLOWVIEW_UPDATE_EDIT',
|
||||||
UPLOAD_CONTENT = 'UI_FLOWVIEW_UPLOAD_CONTENT',
|
UPLOAD_CONTENT = 'UI_FLOWVIEW_UPLOAD_CONTENT',
|
||||||
SET_SHOW_FULL_CONTENT = 'UI_SET_SHOW_FULL_CONTENT',
|
SET_SHOW_FULL_CONTENT = 'UI_SET_SHOW_FULL_CONTENT',
|
||||||
SET_CONTENT_VIEW_DESCRIPTION = "UI_SET_CONTENT_VIEW_DESCRIPTION",
|
SET_CONTENT_VIEW_DESCRIPTION = "UI_SET_CONTENT_VIEW_DESCRIPTION"
|
||||||
SET_CONTENT_VIEW_SELECTOR = "UI_SET_CONTENT_VIEW_SELECTOR"
|
|
||||||
|
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
displayLarge: false,
|
displayLarge: false,
|
||||||
contentViewDescription: '',
|
contentViewDescription: '',
|
||||||
showFullContent: false,
|
showFullContent: false,
|
||||||
isContentViewSelectorOpen: false,
|
|
||||||
modifiedFlow: false,
|
modifiedFlow: false,
|
||||||
contentView: 'Auto',
|
contentView: 'Auto',
|
||||||
tab: 'request',
|
tab: 'request',
|
||||||
@ -81,13 +79,6 @@ export default function reducer(state = defaultState, action) {
|
|||||||
showFullContent: action.show
|
showFullContent: action.show
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case SET_CONTENT_VIEW_SELECTOR:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
isContentViewSelectorOpen: action.contentViewSelector
|
|
||||||
}
|
|
||||||
|
|
||||||
case SET_TAB:
|
case SET_TAB:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -141,10 +132,6 @@ export function setShowFullContent(show) {
|
|||||||
return { type: SET_SHOW_FULL_CONTENT, show }
|
return { type: SET_SHOW_FULL_CONTENT, show }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setContentViewSelectorOpen(open){
|
|
||||||
return {type: SET_CONTENT_VIEW_SELECTOR, contentViewSelector: open}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateEdit(update) {
|
export function updateEdit(update) {
|
||||||
return { type: UPDATE_EDIT, update }
|
return { type: UPDATE_EDIT, update }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user