{"record":{"id":"4a2b4a062c6445a0","repo":"epi052/feroxbuster","slug":"empty-request-file-file-provided","errorCode":null,"errorMessage":"Empty --request-file file provided","messagePattern":"Empty --request-file file provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/utils.rs","lineNumber":437,"sourceCode":"/// # Details\n///\n/// * The request body is only set if it hasn't been overridden by the CLI options.\n/// * The request line method is added to `config.methods` if it's not already present.\n/// * Headers from the raw request are added to `config.headers`, unless overridden\n///   by CLI options. Special handling is applied to `User-Agent`, `Content-Length`,\n///   and `Cookie` headers.\n/// * The request URI is validated and parsed. If it's not a full URL, it will be\n///   combined with the `Host` header to form a full target URL.\n/// * Query parameters are extracted from the URI and added to `config.queries`,\n///   unless overridden by CLI options.\n///\npub fn parse_request_file(config: &mut Configuration) -> Result<()> {\n    // read in the file (raw bytes) located at config.request_file\n    // parse the file into a Request struct\n    let contents = std::fs::read(&config.request_file)?;\n\n    if contents.is_empty() {\n        bail!(\"Empty --request-file file provided\");\n    }\n\n    // find the first header/body separator\n    // locate both \\r\\n\\r\\n and \\n\\n and pick whichever appears earliest,\n    // so that a \\r\\n\\r\\n inside the body doesn't shadow a \\n\\n separator\n    // that terminates the headers\n    let crlf = contents.windows(4).position(|w| w == b\"\\r\\n\\r\\n\");\n    let lf = contents.windows(2).position(|w| w == b\"\\n\\n\");\n\n    let (sep_idx, sep_len) = match (crlf, lf) {\n        (Some(c), Some(l)) => {\n            if c <= l {\n                (c, 4)\n            } else {\n                (l, 2)\n            }\n        }\n        (Some(c), None) => (c, 4),","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/epi052/feroxbuster/blob/1f595dab5c76858d5a14fbc47dabf2563d729c62/src/config/utils.rs#L419-L455","documentation":"parse_request_file reads the file named by `config.request_file` and parses it as a raw HTTP request. If the file exists but contains zero bytes, no request can be parsed, so it throws this error. This catches the case of a valid path pointing at an empty file.","triggerScenarios":"Running with `--request-file <path>` where the file exists but is 0 bytes; creating a placeholder file with `touch` and forgetting to fill it.","commonSituations":"`touch req.txt` placeholders, editors/tools that truncated the file, failed downloads or redirect outputs (`curl -o`) that wrote nothing, or scripts creating the file but erroring before writing content.","solutions":["Fill the request file with a valid raw HTTP request (request line, headers, blank line, optional body)","Re-export or re-download the request file if it was truncated","Check the file size (`ls -l`) before running and confirm it is non-empty"],"exampleFix":"// before (empty file)\ntouch request.txt\n// after\nprintf 'GET / HTTP/1.1\\r\\nHost: example.com\\r\\n\\r\\n' > request.txt","handlingStrategy":"validation","validationCode":"let meta = std::fs::metadata(&path)?;\nif meta.len() == 0 { return Err(anyhow!(\"request file {path:?} is empty\")); }","typeGuard":null,"tryCatchPattern":"match std::fs::read(&path) {\n    Ok(bytes) if !bytes.is_empty() => parse_request(bytes),\n    Ok(_) => eprintln!(\"request file is empty\"),\n    Err(e) => eprintln!(\"cannot read request file: {e}\"),\n}","preventionTips":["Check file size (ls -l or fs::metadata) before passing --request-file","Never use bare `touch` placeholders for request files","Confirm write/export pipelines actually wrote content (non-zero exit, bytes written)"],"tags":["request-file","http","validation","rust"],"backgroundTag":"empty-required-field","analyzedSha":"1f595dab5c76858d5a14fbc47dabf2563d729c62","analyzedAt":"2026-09-13T19:33:06.208Z","contentChangedAt":"2026-09-13T19:33:06.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}