Document use case: http::formatQuery key
http::formatQuery key value ?key value ...?
The function is also usable as:
http::formatQuery stringwhich just does the %xx translation for string.
For me (and Rolf via chat), this is a helpful use case.
Could we make this offical and document this use case ?
Thank you, Harald
Fixed in TIP 452 branch by having formatQuery raise an error if passed an odd number of arguments. Creating new ticket to request that ::http::quoteString be exposed that will just do the %XX translation for a string.
I guess that we can review how we do the quoting once this hits a main branch. It's the sort of thing for which I did regsub -command after all.
I would really enjoy to legalize this use-case. Should I start a tip ? Thank you, Harald
Hi Harald, Does the "new" command ::http::quoteString do what you need? If so, this bug can be closed. Best wishes, Keith.
Thank you, Nash, for the message, first, I am amazed about all the patches this week, great.
To answer the discrete question: I look to the msgcat code in [dcc2f0bb90d2ced6].
http::quoteString is aliased on http::mapReply.
The function is great and what is IMHO helpful.
But mapReply starts with:
if {$http(-urlencoding) ne ""} {
so, the http array must exist to use it. So, IMHO, it can not be used as an utility function disconnected from a http request (what was my intention).
As a side note, I am not sure what the "encoding convertto" following it does. If there is encoding envolved, I would do that after the percent encoding, not before, as an encoding applies to the percent encoded characters to.
Just my two pence, Harald
Hi Harald,
I'm not sure what your use case is. How would this command be useful for msgcat?
The array ::http::http is defined when package http is loaded: there is no need to make a HTTP request. You can use http::mapReply without ever making a request.
The "encoding convertto" is essential to produce a %-encoded string that corresponds to a sequence of bytes in a specific character set. Normally we use the default utf-8, e.g.
% package require http 2.10a1 % http::mapReply © %C2%A9
But if the recipient is expecting a different character set, the command can do that too:
% http::config -urlencoding iso8859-1 % http::mapReply © %A9
In HTTP applications there is no need to do encoding after the percent-encoding, because the latter produces a string in a subset of ASCII that HTTP clients and servers are required by the RFCs to understand.
Kind regards,
Keith.
Sorry, Nash, all ok. My Covid-limitted brain just did not get it and thought the other way around. Like that it is ok and helpful.
Thank you for all the work and take care, Harald
Thanks, @kjnash, for taking all those tickets regarding the http package. Whenever you feel that the documentation is OK, just go ahead. I'm GTG.