2022-02-22 14:10:39 +01:00
|
|
|
import { Typography } from "@mui/material";
|
|
|
|
|
|
|
|
import HttpStatusIcon from "./HttpStatusIcon";
|
2022-02-23 15:20:23 +01:00
|
|
|
|
|
|
|
import { HttpProtocol } from "lib/graphql/generated";
|
2022-02-22 14:10:39 +01:00
|
|
|
|
|
|
|
type ResponseStatusProps = {
|
|
|
|
proto: HttpProtocol;
|
|
|
|
statusCode: number;
|
|
|
|
statusReason: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
function mapProto(proto: HttpProtocol): string {
|
|
|
|
switch (proto) {
|
2022-02-27 17:55:41 +01:00
|
|
|
case HttpProtocol.Http10:
|
|
|
|
return "HTTP/1.0";
|
|
|
|
case HttpProtocol.Http11:
|
2022-02-22 14:10:39 +01:00
|
|
|
return "HTTP/1.1";
|
2022-02-27 17:55:41 +01:00
|
|
|
case HttpProtocol.Http20:
|
2022-02-22 14:10:39 +01:00
|
|
|
return "HTTP/2.0";
|
|
|
|
default:
|
|
|
|
return proto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-23 15:20:23 +01:00
|
|
|
export default function ResponseStatus({ proto, statusCode, statusReason }: ResponseStatusProps): JSX.Element {
|
2022-02-22 14:10:39 +01:00
|
|
|
return (
|
|
|
|
<Typography variant="h6" style={{ fontSize: "1rem", whiteSpace: "nowrap" }}>
|
|
|
|
<HttpStatusIcon status={statusCode} />{" "}
|
|
|
|
<Typography component="span" color="textSecondary">
|
|
|
|
<Typography component="span" color="textSecondary" style={{ fontFamily: "'JetBrains Mono', monospace" }}>
|
|
|
|
{mapProto(proto)}
|
|
|
|
</Typography>
|
|
|
|
</Typography>{" "}
|
|
|
|
{statusCode} {statusReason}
|
|
|
|
</Typography>
|
|
|
|
);
|
|
|
|
}
|