pub struct Response {
pub status_code: u16,
pub headers: BTreeMap<String, String>,
pub body: Vec<u8>,
pub title: Option<String>,
}Expand description
HTTP Response
Fields§
§status_code: u16§headers: BTreeMap<String, String>§body: Vec<u8>§title: Option<String>Implementations§
Source§impl Response
impl Response
pub fn ok(body: Vec<u8>) -> Self
Sourcepub fn body_as_string(&self) -> String
pub fn body_as_string(&self) -> String
Examples found in repository?
examples/real_network.rs (line 43)
8fn main() {
9 println!("╔══════════════════════════════════════════════════════════════════╗");
10 println!("║ avx BROWSER - REAL NETWORK MODE ║");
11 println!("║ Making actual HTTP requests through 7 layers ║");
12 println!("╚══════════════════════════════════════════════════════════════════╝");
13 println!();
14
15 // Create browser with maximum security
16 let config = BrowserConfig::default();
17 let mut browser = Browser::new(config);
18
19 println!("✓ Browser initialized with 7-layer protection");
20 println!();
21
22 // List of test URLs
23 let test_urls = vec![
24 "http://example.com",
25 "http://info.cern.ch",
26 "http://neverssl.com",
27 ];
28
29 println!("📡 Testing real network requests...");
30 println!();
31
32 for url in test_urls {
33 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
34 println!("🔗 URL: {}", url);
35 println!();
36
37 match browser.navigate(url) {
38 Ok(response) => {
39 println!("✅ SUCCESS!");
40 println!(" Status: {}", response.status_code);
41 println!(" Body size: {} bytes", response.body.len());
42
43 let body_str = response.body_as_string();
44 let preview_len = body_str.len().min(200);
45 println!(" Preview:");
46 println!(" ┌─────────────────────────────────────────────");
47 for line in body_str[..preview_len].lines().take(5) {
48 println!(" │ {}", line);
49 }
50 if body_str.len() > preview_len {
51 println!(" │ ... ({} more bytes)", body_str.len() - preview_len);
52 }
53 println!(" └─────────────────────────────────────────────");
54 }
55 Err(e) => {
56 println!("❌ FAILED: {:?}", e);
57 println!(" Note: Some URLs may require HTTPS or be unreachable");
58 }
59 }
60
61 println!();
62 }
63
64 // Show statistics
65 let stats = browser.security_metrics();
66 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
67 println!("📊 Session Statistics:");
68 println!(" Requests made: {}", browser.history.len());
69 println!(" Cache size: {}", browser.cache.len());
70 println!(" Active layers: {}", stats.layers_active);
71 println!(" Anonymity level: {:.2}%", stats.anonymity_level * 100.0);
72 println!(" Total latency: {} ms", stats.latency_overhead_ms);
73 println!(" Bandwidth overhead: {:.2}x", stats.bandwidth_overhead);
74 println!();
75
76 // Clear data
77 println!("🧹 Clearing browsing data...");
78 browser.clear_data();
79 println!("✓ All traces removed");
80 println!();
81
82 println!("╔══════════════════════════════════════════════════════════════════╗");
83 println!("║ REAL NETWORK TEST COMPLETE ║");
84 println!("║ All requests routed through 7 layers ║");
85 println!("╚══════════════════════════════════════════════════════════════════╝");
86}More examples
examples/browser_demo.rs (line 62)
5fn main() {
6 println!("╔══════════════════════════════════════════════════════════════╗");
7 println!("║ avx BROWSER - Ultra-Secure Web Browser ║");
8 println!("║ 7-Layer Anonymity Protection (vs 3 in Tor) ║");
9 println!("╚══════════════════════════════════════════════════════════════╝\n");
10
11 // 1. Create browser with maximum security
12 println!("1. Initializing browser with 7-layer protection...\n");
13
14 let config = BrowserConfig {
15 num_layers: 7,
16 tor_enabled: true,
17 vpn_enabled: true,
18 i2p_enabled: true,
19 obfuscation_enabled: true,
20 enable_javascript: false, // Disabled for security
21 block_trackers: true,
22 block_advertisements: true,
23 ..Default::default()
24 };
25
26 let mut browser = Browser::new(config);
27
28 // 2. Show protection layers
29 println!(" Protection Layers Active:");
30 println!(" ┌─────────────────────────────────────────────────────┐");
31
32 for (i, layer) in browser.layer_stack.layers.iter().enumerate() {
33 let status = if layer.enabled { "✓" } else { "✗" };
34 println!(" │ {} Layer {}: {:?} ({} ms latency)",
35 status, i + 1, layer.layer_type, layer.latency_ms);
36 }
37
38 println!(" └─────────────────────────────────────────────────────┘\n");
39
40 // 3. Security metrics
41 let metrics = browser.security_metrics();
42
43 println!("2. Security Metrics:");
44 println!(" Active Layers: {}", metrics.layers_active);
45 println!(" Anonymity Level: {:.2}% (vs 87.5% in Tor)", metrics.anonymity_level * 100.0);
46 println!(" Latency Overhead: {} ms", metrics.latency_overhead_ms);
47 println!(" Bandwidth Overhead: {:.2}x", metrics.bandwidth_overhead);
48 println!();
49
50 // 4. Navigate to a URL
51 println!("3. Navigating to example.com...\n");
52
53 match browser.navigate("https://example.com") {
54 Ok(response) => {
55 println!(" ✓ Response received!");
56 println!(" Status Code: {}", response.status_code);
57 println!(" Body Size: {} bytes", response.body.len());
58 println!(" Title: {}",
59 response.title.clone().unwrap_or_else(|| "N/A".to_string()));
60
61 // Show body preview
62 let body_preview = response.body_as_string();
63 let preview = if body_preview.len() > 100 {
64 format!("{}...", &body_preview[..100])
65 } else {
66 body_preview
67 };
68
69 println!("\n Body Preview:");
70 println!(" {}", preview);
71 }
72 Err(e) => {
73 println!(" ✗ Error: {:?}", e);
74 }
75 }
76
77 println!("\n4. Browser Statistics:");
78 println!(" Cached Pages: {}", browser.cache.len());
79 println!(" Cookies: {}", browser.cookies.len());
80 println!(" History Entries: {}", browser.history.len());
81
82 // 5. Scientific analysis
83 println!("\n5. Scientific Analysis:");
84 println!(" ┌─────────────────────────────────────────────────────┐");
85 println!(" │ ANONYMITY LEVEL CALCULATION │");
86 println!(" │ │");
87 println!(" │ Formula: A = 1 - (1 / 2^n) │");
88 println!(" │ where n = number of layers │");
89 println!(" │ │");
90 println!(" │ Tor (3 layers): A = 1 - 1/8 = 0.875 (87.5%) │");
91 println!(" │ avx (7 layers): A = 1 - 1/128 = 0.992 (99.2%) │");
92 println!(" │ │");
93 println!(" │ Improvement: 99.2% / 87.5% = 1.13x more anonymous │");
94 println!(" └─────────────────────────────────────────────────────┘");
95
96 println!("\n ┌─────────────────────────────────────────────────────┐");
97 println!(" │ INFORMATION ENTROPY │");
98 println!(" │ │");
99 println!(" │ Shannon Entropy: H(X) = log₂(N) │");
100 println!(" │ where N = possible paths │");
101 println!(" │ │");
102 println!(" │ Tor (3 layers): H = log₂(2^8) = 8 bits │");
103 println!(" │ avx (7 layers): H = log₂(2^56) = 56 bits │");
104 println!(" │ │");
105 println!(" │ Possible Paths: 72,057,594,037,927,936 (72 PB) │");
106 println!(" └─────────────────────────────────────────────────────┘");
107
108 println!("\n ┌─────────────────────────────────────────────────────┐");
109 println!(" │ TRAFFIC ANALYSIS RESISTANCE │");
110 println!(" │ │");
111 println!(" │ Correlation Coefficient: ρ = cov(X,Y)/(σ_X × σ_Y) │");
112 println!(" │ │");
113 println!(" │ No Protection: ρ ≈ 0.95 (easily correlated) │");
114 println!(" │ Tor (3 layers): ρ ≈ 0.70 (moderately hard) │");
115 println!(" │ avx (7 layers): ρ < 0.30 (very difficult) │");
116 println!(" │ │");
117 println!(" │ With timing jitter: ρ < 0.10 (near impossible) │");
118 println!(" └─────────────────────────────────────────────────────┘");
119
120 // 6. Clear data
121 println!("\n6. Clearing browsing data...");
122 browser.clear_data();
123 println!(" ✓ Cache cleared");
124 println!(" ✓ Cookies cleared");
125 println!(" ✓ History cleared");
126
127 println!("\n╔══════════════════════════════════════════════════════════════╗");
128 println!("║ SESSION COMPLETE ║");
129 println!("║ No traces left. Complete anonymity achieved. ║");
130 println!("╚══════════════════════════════════════════════════════════════╝");
131}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)