util::http::curl::request (private)
util::http::curl::request [ -url url ] [ -method method ] \ [ -headers headers ] [ -body body ] [ -body_file body_file ] \ [ -delete_body_file ] [ -files files ] [ -timeout timeout ] \ [ -depth depth ] [ -max_depth max_depth ] [ -force_ssl ] \ [ -gzip_request ] [ -gzip_response ] [ -post_redirect ] [ -spool ]
Defined in packages/acs-tcl/tcl/http-client-procs.tcl
Issue an HTTP request either GET or POST to the url specified. This is the curl wrapper implementation, used on AOLserver and when ssl native capabilities are not available.
- Switches:
- -url (optional)
- -method (optional, defaults to
"GET"
)- -headers (optional)
- specifies an ns_set of extra headers to send to the server when doing the request. Some options exist that allow one to avoid the need to specify headers manually, but headers will always take precedence over options.
- -body (optional)
- is the payload for the request and will be passed as is (useful for many purposes, such as webDav). A convenient way to specify form variables for POST payloads through this argument is passing a string obtained by 'export_vars -url'.
- -body_file (optional)
- is an alternative way to specify the payload, useful in cases such as the upload of big files by POST. If specified, will have precedence over the 'body' parameter. Content of the file won't be encoded according with the content type of the request as happen with 'body'
- -delete_body_file (optional, boolean)
- decides whether remove body payload file once the request is over.
- -files (optional)
- curl is natively capable to send files via POST requests, and exploiting it can be desirable to send very large files via POST, because no extra space will be required on the disk to prepare the request payload using this feature. Files by this parameter are couples in the form '{ form_field_name file_path_on_filesystem }'
- -timeout (optional, defaults to
"30"
)- Timeout in seconds. The value can be an integer, a floating point number or an ns_time value. Since curl versions before 7.32.0 just accept integer, the granularity is set to seconds.
- -depth (optional, defaults to
"0"
)- -max_depth (optional, defaults to
"10"
)- is the maximum number of redirects the proc is allowed to follow. A value of 0 disables redirection. When max depth for redirection has been reached, proc will return response from the last page we were redirected to. This is important if redirection response contains data such as cookies we need to obtain anyway. Be aware that when following redirects, unless it is a code 303 redirect, url and POST urlencoded variables will be sent again to the redirected host. Multipart variables won't be sent again. Sending to the redirected host can be dangerous, if such host is not trusted or uses a lower level of security.
- -force_ssl (optional, boolean)
- is ignored when using curl HTTP client implementation and is only kept for cross compatibility.
- -gzip_request (optional, boolean)
- informs the server that we are sending data in gzip format. Data will be automatically compressed. Notice that not all servers can treat gzipped requests properly, and in such cases response will likely be an error.
- -gzip_response (optional, boolean)
- informs the server that we are capable of receiving gzipped responses. If server complies to our indication, the result will be automatically decompressed.
- -post_redirect (optional, boolean)
- decides what happens when we are POSTing and server replies with 301, 302 or 303 redirects. RFC 2616/10.3.2 states that method should not change when 301 or 302 are returned, and that GET should be used on a 303 response, but most HTTP clients fail in respecting this and switch to a GET request independently. This option forces this kinds of redirect to conserve their original method. Be aware that curl allows the POSTing of 303 requests only since version 7.26. Versions prior than this will follow 303 redirects by GET method. If following by POST is a requirement, please consider switching to the native HTTP client implementation, or update curl.
- -spool (optional, boolean)
- enables file spooling of the request on the file specified. It is useful when we expect large responses from the server. The result is spooled to a temporary file, the name is returned in the file component of the result.
- Returns:
- the data as dict with elements 'headers', 'page', 'file', 'status', 'time' (elapsed request time in ns_time format), and 'modified'.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.