mirror of
https://github.com/tlsnotary/proof_viz.git
synced 2026-01-08 20:07:56 -05:00
Show the number of bytes send/received
+ clippy and cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use gloo::console::log;
|
||||
use std::fmt;
|
||||
// use gloo::console::log;
|
||||
// use std::fmt;
|
||||
|
||||
use spansy::http::parse_response;
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -26,11 +26,11 @@ enum ContentType {
|
||||
Other,
|
||||
}
|
||||
fn get_content_type(bytes: &[u8]) -> (ContentType, String) {
|
||||
match parse_response(&bytes) {
|
||||
match parse_response(bytes) {
|
||||
Ok(x) => {
|
||||
// log!(format!("Test {:?}", x.headers));
|
||||
|
||||
let content_type = (&x)
|
||||
let content_type = x
|
||||
.headers
|
||||
.iter()
|
||||
.find(|h| h.name.as_str().to_lowercase() == "content-type")
|
||||
@@ -58,7 +58,7 @@ fn get_content_type(bytes: &[u8]) -> (ContentType, String) {
|
||||
#[function_component]
|
||||
pub fn ContentIFrame(props: &Props) -> Html {
|
||||
// JavaScript function to trigger Prism highlighting
|
||||
use_effect(move || highlight_code());
|
||||
use_effect(highlight_code);
|
||||
|
||||
match get_content_type(&props.bytes) {
|
||||
(ContentType::Html, content_html) => html! {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use elliptic_curve::{pkcs8::DecodePublicKey, PublicKey};
|
||||
use elliptic_curve::pkcs8::DecodePublicKey;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use gloo::console::log;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{fmt, ops::Range};
|
||||
|
||||
use gloo::console::log;
|
||||
// use gloo::console::log;
|
||||
use yew::prelude::*;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
@@ -27,18 +27,16 @@ pub struct Props {
|
||||
}
|
||||
|
||||
fn get_redacted_string(redacted_char: &char, size: usize) -> String {
|
||||
if true || size < 10 {
|
||||
if true
|
||||
/*|| size < 10*/
|
||||
{
|
||||
redacted_char.to_string().repeat(size)
|
||||
} else {
|
||||
format! {"{}...{}", redacted_char.to_string().repeat(3), redacted_char.to_string().repeat(3)}
|
||||
}
|
||||
}
|
||||
|
||||
fn redactions_in_red(
|
||||
bytes: &Vec<u8>,
|
||||
redacted_ranges: &Vec<Range<usize>>,
|
||||
redacted_char: &char,
|
||||
) -> Html {
|
||||
fn redactions_in_red(bytes: &[u8], redacted_ranges: &[Range<usize>], redacted_char: &char) -> Html {
|
||||
if redacted_ranges.is_empty() {
|
||||
return Html::from(String::from_utf8(bytes.to_vec()).unwrap());
|
||||
}
|
||||
@@ -100,9 +98,14 @@ pub fn RedactedBytesComponent(props: &Props) -> Html {
|
||||
redacted_ranges,
|
||||
} = props;
|
||||
|
||||
let size = bytes.len();
|
||||
let redacted_size = redacted_ranges
|
||||
.iter()
|
||||
.fold(0, |acc, r| acc + r.end - r.start);
|
||||
|
||||
html! {
|
||||
<details class="p-4 w-5/6" open={true}>
|
||||
<summary><b>{"Bytes "}{direction}{": " }</b></summary>
|
||||
<summary><b>{"Bytes "}{direction}{": " }</b>{"("}{size}{"B, redacted:"}{redacted_size}{"B)"}</summary>
|
||||
<div class="bg-black text-white p-4 rounded-md overflow-x-auto">
|
||||
<pre>{redactions_in_red(bytes, redacted_ranges, redacted_char)}</pre>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user