HTTP Client
The Guardian http command provides an HTTP(S) client to Tcl scripts.
It is currently based on ureq, but this is not guaranteed.
Important
This command is upcoming in 0.6.0 and has not been released yet.
Note
The
httpcommand currently requires the URL to be untainted, and taints the response data and response headers. Query parameters and request headers are not currently required to be untainted, but this is not guaranteed and feedback is welcome on what should be checked for tainted data.
Tip
The
platform-sslRust feature, enabled by default, uses the host platform’s SSL certificates and validation logic HTTPS certificates. If this feature is disabled, a built-in certificate bundle is used.
HTTP GET
The http get command exposes GET requests:
http get ?-query dict? ?-headers dict? ?-headers-out var? ?-out-file file? ?-binary? url
- -query dict
-
Add query parameters to the request from the dictionary dict.
- -headers dict
-
Add HTTP request headers from the dictionary dict.
- -headers-out var
-
Save response headers to a dictionary in variable var.
- -out-file file
-
Save output to file instead of returning it. Saves the data directly, ignoring
-binary. - -binary
-
Return binary output instead of decoding to string.
Note
This just uses
read_to_vec()instead ofread_to_string(). When it is not supplied, it is not clear ifureqdecodes according to the content-encoding, or just treats data as UTF-8.