/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ import {Request, Response, Header, Insights, RetryInsights} from './types'; import { Component, FlexColumn, ManagedTable, ManagedDataInspector, Text, Panel, Select, styled, colors, SmallText, } from 'flipper'; import {decodeBody, getHeaderValue} from './utils'; import {formatBytes, BodyOptions} from './index'; import React from 'react'; import querystring from 'querystring'; import xmlBeautifier from 'xml-beautifier'; const WrappingText = styled(Text)({ wordWrap: 'break-word', width: '100%', lineHeight: '125%', padding: '3px 0', }); const KeyValueColumnSizes = { key: '30%', value: 'flex', }; const KeyValueColumns = { key: { value: 'Key', resizable: false, }, value: { value: 'Value', resizable: false, }, }; type RequestDetailsProps = { request: Request; response: Response | null | undefined; bodyFormat: string; onSelectFormat: (bodyFormat: string) => void; }; export default class RequestDetails extends Component { static Container = styled(FlexColumn)({ height: '100%', overflow: 'auto', }); urlColumns = (url: URL) => { return [ { columns: { key: {value: Full URL}, value: { value: {url.href}, }, }, copyText: url.href, key: 'url', }, { columns: { key: {value: Host}, value: { value: {url.host}, }, }, copyText: url.host, key: 'host', }, { columns: { key: {value: Path}, value: { value: {url.pathname}, }, }, copyText: url.pathname, key: 'path', }, { columns: { key: {value: Query String}, value: { value: {url.search}, }, }, copyText: url.search, key: 'query', }, ]; }; render() { const {request, response, bodyFormat, onSelectFormat} = this.props; const url = new URL(request.url); const formattedText = bodyFormat == BodyOptions.formatted; return ( {url.search ? ( ) : null} {request.headers.length > 0 ? ( ) : null} {request.data != null ? ( ) : null} {response ? ( <> {response.headers.length > 0 ? ( ) : null} ) : null}