GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — clibrowser/src/commands/navigate.rs at main · allthingssecurity/clibrowser

Expand file tree

/

navigate.rs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
59 lines (52 loc) · 1.6 KB
/

navigate.rs

Copy path

File metadata and controls

59 lines (52 loc) · 1.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use anyhow::Result;
use serde::Serialize;
use crate::cli::GetArgs;
use crate::http;
use crate::output::OutputConfig;
use crate::session::Session;
#[derive(Serialize)]
struct GetResult {
url: String,
status: u16,
content_type: Option<String>,
content_length: usize,
redirected_from: Option<String>,
}
pub async fn execute(args: GetArgs, session: &mut Session, out: &OutputConfig) -> Result<i32> {
let response = http::fetch(&args, session).await?;
let result = GetResult {
url: response.url.clone(),
status: response.status,
content_type: response.content_type.clone(),
content_length: response.body.len(),
redirected_from: response.redirected_from.clone(),
};
if out.json {
out.print_json(&result);
} else {
let status_text = if response.status < 400 { "OK" } else { "ERROR" };
let ct = response.content_type.as_deref().unwrap_or("unknown");
let size = format_size(response.body.len());
out.print_human(&format!(
"{} {} | {} | {} | {}",
response.status, status_text, response.url, ct, size
));
if let Some(ref from) = response.redirected_from {
out.print_human(&format!(" redirected from: {}", from));
}
}
if response.status >= 400 {
Ok(2)
} else {
Ok(0)
}
}
fn format_size(bytes: usize) -> String {
if bytes < 1024 {
format!("{}B", bytes)
} else if bytes < 1024 * 1024 {
format!("{:.1}KB", bytes as f64 / 1024.0)
} else {
format!("{:.1}MB", bytes as f64 / (1024.0 * 1024.0))
}
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.