/** * 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 React from 'react'; import {Component} from 'react'; import querystring from 'querystring'; import xmlBeautifier from 'xml-beautifier'; import {Base64} from 'js-base64'; import { DataInspector, Layout, Panel, styled, theme, CodeBlock, } from 'flipper-plugin'; import {Select, Typography} from 'antd'; import {bodyAsBinary, bodyAsString, formatBytes, getHeaderValue} from './utils'; import {Request, Header, Insights, RetryInsights} from './types'; import {BodyOptions} from './index'; import {ProtobufDefinitionsRepository} from './ProtobufDefinitionsRepository'; import {KeyValueItem, KeyValueTable} from './KeyValueTable'; import {CopyOutlined} from '@ant-design/icons'; const {Text} = Typography; type RequestDetailsProps = { request: Request; bodyFormat: string; onSelectFormat: (bodyFormat: string) => void; onCopyText(test: string): void; }; export default class RequestDetails extends Component { urlColumns = (url: URL) => { return [ { key: 'Full URL', value: url.href, }, { key: 'Host', value: url.host, }, { key: 'Path', value: url.pathname, }, { key: 'Query String', value: url.search, }, ]; }; render() { const {request, bodyFormat, onSelectFormat, onCopyText} = this.props; const url = new URL(request.url); const formattedText = bodyFormat == 'formatted'; return ( <> {url.search ? ( ) : null} {request.requestHeaders.length > 0 ? ( ) : null} {request.requestData != null ? ( { e.stopPropagation(); onCopyText(request.requestData as string); }} /> ) : null } pad> ) : null} {request.status ? ( <> {request.responseHeaders?.length ? ( ) : null} { e.stopPropagation(); onCopyText(request.responseData as string); }} /> ) : null } pad> ) : null} Body formatting: