http-client-procs.tcl

  • last updated 5 hours ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Cleanup of external binaries: always use "util::which" to resolve binaries

Background: it is important to always use the same binaries of some

programs. This is important for security reasons, consistency, and

configurability (some operating systems have read-only file systems,

which might be on the path and should be avoided for some operations).

  1. … 3 more files in changeset.
Prefer ns_base64encode where we already require modern NaviServer

Make use of new API "ad_mktmpdir" and "ad_opentmpfile" instead of "ad_tmpnam"

  1. … 7 more files in changeset.
Fix self-inflicted bug: one should indeed be able to specify the same form var multiple time, test the behavior for the future

  1. … 2 more files in changeset.
Extend util::http::post_payload and util::http::post to receive form varaibles also in dict form, update documentation

Cleanup leftover arguments

Factor the payload building behavior in util::http::post into its own proc, so that it can be reused elsewhere

Make api public

Reduce usage of ns_mktemp in OpenACS

ns_mktemp uses the deprecated old POSIX call mktemp(), which should

not be used anymore for security reasons (race between the name

creation and opening the file). This change removes several usages of

"ns_mktemp" from OpenACS and replaces it with calls to the

safe Tcl call "file tempfile ..." (introduced by Tcl 8.6).

  1. … 7 more files in changeset.
Remove extra decoding ns_parsequery provides it already

Use naviserver api to parse URL variables

  1. … 1 more file in changeset.
Revert to previous strategy of determining available subcommands.

Running the provided subcommand is dangerous, since the command might

have side effects, might require connections, etc.

The feature test for "ns_http run" was incorrect, since it was not

introduced with 4.99.15 (as the comment suggested), but already with

4.99.4 (2017)... but at this time, the command did not return a dict,

which is assumed in the http-client procs. One can use "ns_http stats"

as an indicator for this feature, which was introduced at the time

when "ns_http run" was starting to return dicts as results.

Provide a more precise name for the feature test of ns_http returning

dicts (naming the feature simply "ns_http" is not a good idea, since

the command could of course be used already before the feature change).

  1. … 2 more files in changeset.
Do not improperly rely on apm_version_names_compare to check for NaviServer version number, use a more reliable capability check instead

  1. … 1 more file in changeset.
Keep supporting the previous proc signature, throwing a warning

util::http should provide enough fallback via curl already without targeting specific Naviserver versions, use other fallbacks only when no implementation is available

  1. … 1 more file in changeset.
Fix webserver version check using 'apm_version_names_compare' for rc versions.

Between 4.99.6 and 4.99.20rc1, for example, 'apm_version_names_compare' will consider the latter to be the lowest.

As this is not the expected behavior for webserver version check, this patch just removes the rc part of the version before comparing in the few cases where this is done, and should be removed if the behavior changes in the future.

  1. … 1 more file in changeset.
Fix version check

Tear down a lot of boilerplate used to support native HTTP api on Naviserver versions < 4.99.15, which will now fallback to curl

  1. … 1 more file in changeset.
Doc formatting changes

Avoid markup in documentation

Reduce people expectations

Prefer 'namespace which' over 'info commands', as it is faster (on local tests, around 2x) and returns a single value. Many thanks to Nathan Coulter.

  1. … 58 more files in changeset.
improve spelling

  1. … 4 more files in changeset.
improve spelling

  1. … 6 more files in changeset.
improve spelling

  1. … 5 more files in changeset.
added support for SNI servers

introduced "ad_file" as a means to avoid unexpected tilde substitution in file names

  1. … 50 more files in changeset.
improve spelling: move closer to the linux documentation recommendations

  1. … 34 more files in changeset.
Satisfy acs-tcl.postman_echo test case for curl http client implementation:

as with curl we always spool the body of requests into a file, we need to convert to the proper encoding even when this is already that of the system

Wrap legacy and current ns_http api behavior in a proc with a common interface in a way that people with newer Naviserver can exploit e.g. ns_http run capabilities (in particular, not being forced to queue and potentially block concurrent HTTP requests)