http-client-procs.tcl

  • last updated 17 hours ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
merge from oacs-5-10

  1. … 8099 more files in changeset.
Use ns_parseurl to validate the URL and to determine the hostname

Fixes for regression test: util_http_json_encoding

This change corrects 2 bugs, causing the regression test to fail under certain circumstances:

1) use for test location [::acs::test::url] instead of [ad_url]

The call [::acs::test::url] should be used for all tests in the regression tests and avoids

problems with wrong URLs when running e.g. in a container

2) When running on a setup with self-signed certificates, the curl requests require a "-k"

flag to be passed. Otherwise, the regression test fails.

  1. … 1 more file in changeset.
After further consideration, ns_absoluteurl is actually sufficient to preform location header completion on its own and does not need a wrapper utility

  1. … 3 more files in changeset.
Streamline terminology with other occurrences in OpenACS and NaviServer/AOLserver

- the term "location" is usually used in OpenACS/NaviServer/AOLserver for the

part of a URL before the path (i.e. SCHEME+HOST+PORT)

- the new function util::absolute_url is a value-added version of NaviServer's "ns_absoluteurl".

This is now documented with its differences, and aligned with its terminology

  1. … 2 more files in changeset.
Introduce util::complete_location

This utility is meant to require the value of the Location header in an HTTP response to be completed vith the host coming from a reference complete URL, which is normally that of the redirected request.

It is intended for use in the context of HTTP client APIs, where we want to handle server responses affected by https://www.rfc-editor.org/rfc/rfc7231#section-7.1.2

  1. … 3 more files in changeset.
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.