/** @jsx React.DOM */ var FlowDetailNav = React.createClass({ render: function(){ var items = this.props.tabs.map(function(e){ var str = e.charAt(0).toUpperCase() + e.slice(1); var className = this.props.active === e ? "active" : ""; var onClick = function(){ this.props.selectTab(e); return false; }.bind(this); return {str}; }.bind(this)); return ( ); } }); var Headers = React.createClass({ render: function(){ var rows = this.props.message.headers.map(function(header){ return ( {header[0]+":"} {header[1]} ); }); return ( {rows}
); } }); var FlowDetailRequest = React.createClass({ render: function(){ var flow = this.props.flow; var first_line = [ flow.request.method, RequestUtils.pretty_url(flow.request), "HTTP/"+ flow.response.httpversion.join(".") ].join(" "); var content = null; if(flow.request.contentLength > 0){ content = "Request Content Size: "+ formatSize(flow.request.contentLength); } else { content =
No Content
; } //TODO: Styling return (
{ first_line }
{content}
); } }); var FlowDetailResponse = React.createClass({ render: function(){ var flow = this.props.flow; var first_line = [ "HTTP/"+ flow.response.httpversion.join("."), flow.response.code, flow.response.msg ].join(" "); var content = null; if(flow.response.contentLength > 0){ content = "Response Content Size: "+ formatSize(flow.response.contentLength); } else { content =
No Content
; } //TODO: Styling return (
{ first_line }
{content}
); } }); var TimeStamp = React.createClass({ render: function() { var ts, delta; if(!this.props.t && this.props.optional){ //should be return null, but that triggers a React bug. return ; } else if (!this.props.t){ ts = "active"; } else { ts = (new Date(this.props.t * 1000)).toISOString(); ts = ts.replace("T", " ").replace("Z",""); if(this.props.deltaTo){ delta = Math.round((this.props.t-this.props.deltaTo)*1000) + "ms"; delta = {"(" + delta + ")"}; } else { delta = null; } } return {this.props.title + ":"}{ts} {delta}; } }); var ConnectionInfo = React.createClass({ render: function() { var conn = this.props.conn; var address = conn.address.address.join(":"); var sni = ; //should be null, but that triggers a React bug. if(conn.sni){ sni = TLS SNI:{conn.sni}; } return ( {sni}
Address:{address}
); } }); var CertificateInfo = React.createClass({ render: function(){ //TODO: We should fetch human-readable certificate representation // from the server var flow = this.props.flow; var client_conn = flow.client_conn; var server_conn = flow.server_conn; return (
{client_conn.cert ?

Client Certificate

: null} {client_conn.cert ?
{client_conn.cert}
: null} {server_conn.cert ?

Server Certificate

: null} {server_conn.cert ?
{server_conn.cert}
: null}
); } }); var FlowDetailConnectionInfo = React.createClass({ render: function(){ var flow = this.props.flow; var client_conn = flow.client_conn; var server_conn = flow.server_conn; return (

Client Connection

Server Connection

); } }); var tabs = { request: FlowDetailRequest, response: FlowDetailResponse, details: FlowDetailConnectionInfo }; var FlowDetail = React.createClass({ getDefaultProps: function(){ return { tabs: ["request","response", "details"] }; }, mixins: [StickyHeadMixin], nextTab: function(i) { var currentIndex = this.props.tabs.indexOf(this.props.active); // JS modulo operator doesn't correct negative numbers, make sure that we are positive. var nextIndex = (currentIndex + i + this.props.tabs.length) % this.props.tabs.length; this.props.selectTab(this.props.tabs[nextIndex]); }, render: function(){ var flow = JSON.stringify(this.props.flow, null, 2); var Tab = tabs[this.props.active]; return (
); } });