module

CurlCommand

Shared curl command construction used by the curl output builder and the HTML report's copy-as-curl feature.

Class methods

build(method : String, url : String, body : String, body_type : String, headers : Array(String), cookies : Array(String)) : String
Source
build_multipart(method : String, url : String, text_fields : Array(Tuple(String, String)), file_fields : Array(Tuple(String, String)), headers : Array(String), cookies : Array(String)) : String

Upload endpoints (param_type: file) must use -F so curl sends multipart/form-data. --data-raw cannot carry a file part, and the previous builders simply dropped every file field — POST /modern.php printed only name= while -f postman / OAS kept avatar.

file_fields are (name, path_hint); an empty hint uses the field name as the @filename placeholder (same idea as Postman's empty src).

Text fields go out as --form-string, which curl sends verbatim. Under -F a value opening with < or @ is read from a local file, and a ;type= / ;filename= suffix is parsed as a part attribute — so a --pvalue payload such as <script>… failed with curl error 26, and @/etc/passwd would have uploaded that file. Only the file parts keep -F, because there the @ is the point.

Source
for_endpoint(method : String, baked, params) : String

The curl command for one verb of a baked endpoint: multipart when it has a file field, --data-raw otherwise.

HEAD goes out bodiless: -I refuses to combine with --data-raw/-F.

Source
form_fields(params) : Tuple(Array(Tuple(String, String)), Array(Tuple(String, String)))

An endpoint's multipart (name, value) text and file fields. No file fields means the request is not an upload.

Source
shell_quote(str : String) : String

Line breaks become \r/\n text so a command stays on one line, and any other control character \xNN (ControlChars), so a route carrying \e]8;;… cannot drive the terminal the command is printed to. Lossy: control chars become literal \xNN text in the command, not the original bytes (no ANSI-C $'…' quoting).

Source