Implement BACKLOG.md items: config-only, request limits, URL validation

- Remove CLI options except --config and --test-processing-delay
- Enforce 1026 byte request limit per Gemini spec (1024 + 2 for CRLF)
- Add comprehensive URL parsing with host and port validation
- Reject malformed URIs and wrong ports with 59 Bad Request
- Update tests for new URL parsing signature
- Fix clippy warning in port parsing
This commit is contained in:
Jeena 2026-01-16 11:48:06 +00:00
parent 6a61b562f5
commit f05b9373f1
3 changed files with 38 additions and 37 deletions

View file

@ -41,10 +41,11 @@ pub async fn handle_connection(
mut stream: TlsStream<TcpStream>,
dir: &str,
expected_host: &str,
expected_port: u16,
max_concurrent_requests: usize,
test_processing_delay: u64,
) -> io::Result<()> {
const MAX_REQUEST_SIZE: usize = 4096;
const MAX_REQUEST_SIZE: usize = 1026;
const REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
let mut request_buf = Vec::new();
@ -96,7 +97,7 @@ pub async fn handle_connection(
}
// Parse Gemini URL
let path = match parse_gemini_url(&request, expected_host) {
let path = match parse_gemini_url(&request, expected_host, expected_port) {
Ok(p) => p,
Err(_) => {
logger.log_error(59, "Invalid URL format");