From 08b6cd9bb8a8577152469065010e2a5d697af3f2 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sun, 5 Jul 2026 01:49:31 +0800 Subject: [PATCH] test: firefox detectportal returns HTTP/1.1 --- tests/socks4.rs | 12 +++++++++--- tests/socks5.rs | 12 +++++++++--- tests/tunnel.rs | 11 ++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tests/socks4.rs b/tests/socks4.rs index ffccffa6..c2e85b6e 100644 --- a/tests/socks4.rs +++ b/tests/socks4.rs @@ -5,6 +5,7 @@ use std::{ str, }; +use byte_string::ByteStr; use tokio::{ io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, time::{self, Duration}, @@ -86,7 +87,8 @@ async fn socks4_relay_connect() { let svr = Socks4TestServer::new(SERVER_ADDR, LOCAL_ADDR, PASSWORD, METHOD); svr.run().await; - const HTTP_REQUEST: &[u8] = b"GET /success.txt HTTP/1.0\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\n\r\n"; + const HTTP_REQUEST: &[u8] = + b"GET /success.txt HTTP/1.1\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\nConnection: close\r\n\r\n"; let mut c = Socks4TcpClient::connect(("detectportal.firefox.com", 80), LOCAL_ADDR, Vec::new()) .await @@ -100,6 +102,10 @@ async fn socks4_relay_connect() { let mut buf = Vec::new(); r.read_until(b'\n', &mut buf).await.unwrap(); - let http_status = b"HTTP/1.0 200 OK\r\n"; - assert!(buf.starts_with(http_status)); + let http_status = b"HTTP/1.1 200 OK\r\n"; + assert!( + buf.starts_with(http_status), + "HTTP status line mismatched, got: {:?}", + ByteStr::new(&buf) + ); } diff --git a/tests/socks5.rs b/tests/socks5.rs index 09150785..8422ef48 100644 --- a/tests/socks5.rs +++ b/tests/socks5.rs @@ -5,6 +5,7 @@ use std::{ str, }; +use byte_string::ByteStr; use tokio::{ io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, time::{self, Duration}, @@ -132,7 +133,8 @@ async fn socks5_relay_aead() { .await .unwrap(); - let req = b"GET /success.txt HTTP/1.0\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\n\r\n"; + let req = + b"GET /success.txt HTTP/1.1\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\nConnection: close\r\n\r\n"; c.write_all(req).await.unwrap(); c.flush().await.unwrap(); @@ -141,6 +143,10 @@ async fn socks5_relay_aead() { let mut buf = Vec::new(); r.read_until(b'\n', &mut buf).await.unwrap(); - let http_status = b"HTTP/1.0 200 OK\r\n"; - assert!(buf.starts_with(http_status)); + let http_status = b"HTTP/1.1 200 OK\r\n"; + assert!( + buf.starts_with(http_status), + "HTTP status line mismatched, got: {:?}", + ByteStr::new(&buf) + ); } diff --git a/tests/tunnel.rs b/tests/tunnel.rs index c4f5a10c..987124d0 100644 --- a/tests/tunnel.rs +++ b/tests/tunnel.rs @@ -72,7 +72,8 @@ async fn tcp_tunnel() { // Connect it directly, because it is now established a TCP tunnel with detectportal.firefox.com let mut stream = TcpStream::connect(("127.0.0.1", local_port)).await.unwrap(); - let req = b"GET /success.txt HTTP/1.0\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\n\r\n"; + let req = + b"GET /success.txt HTTP/1.1\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\nConnection: close\r\n\r\n"; stream.write_all(req).await.unwrap(); stream.flush().await.unwrap(); @@ -81,8 +82,12 @@ async fn tcp_tunnel() { let mut buf = Vec::new(); r.read_until(b'\n', &mut buf).await.unwrap(); - let http_status = b"HTTP/1.0 200 OK\r\n"; - assert!(buf.starts_with(http_status)); + let http_status = b"HTTP/1.1 200 OK\r\n"; + assert!( + buf.starts_with(http_status), + "HTTP status line mismatched, got: {:?}", + ByteStr::new(&buf) + ); } #[tokio::test]