Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2016-10-12
12:53 • Ticket [74bc0e44f5] Documentation of http::unregister misses return value st... artifact: 43ba6d4e58 user: oehhar
09:58 • Ticket [74bc0e44f5]: 6 changes artifact: 0e1e5cc2a1 user: dkf
09:58
[74bc0e44f5] Doc tweak. check-in: 238be90a8b user: dkf tags: trunk
09:57
[74bc0e44f5] Doc tweak. check-in: 04fbd1b5dd user: dkf tags: core-8-6-branch
09:57
[74bc0e44f5] Doc tweak. check-in: c24fb3badc user: dkf tags: core-8-5-branch
2016-10-11
13:22 • Ticket [74bc0e44f5] Documentation of http::unregister misses return value st... artifact: 6d5c903e28 user: oehhar
2016-10-08
17:11 • Closed ticket [74bc0e44f5]. artifact: bb81e544d9 user: dkf
17:10
[74bc0e44f5] Document result of [http::unregister]. check-in: 6bae8fa2fd user: dkf tags: trunk
17:10
[74bc0e44f5] Document result of [http::unregister]. check-in: d9391bf225 user: dkf tags: core-8-6-branch
17:10
[74bc0e44f5] Document result of [http::unregister]. check-in: fe8a1bc799 user: dkf tags: core-8-5-branch
17:08 • Ticket [74bc0e44f5] Documentation of http::unregister misses return value st... artifact: 740965b03e user: dkf
17:01 • Ticket [74bc0e44f5]: 3 changes artifact: a650ab3532 user: dkf
2016-09-24
15:12 • Ticket [74bc0e44f5]: 4 changes artifact: cb279314e7 user: oehhar
12:23 • Ticket [74bc0e44f5]: 4 changes artifact: ff23ffaa71 user: patthoyts
2016-09-22
15:52 • Ticket [74bc0e44f5]: 4 changes artifact: b7e7da5316 user: oehhar
15:14 • Ticket [74bc0e44f5]: 4 changes artifact: 8c314ba2c6 user: patthoyts
14:02 • New ticket [74bc0e44f5]. artifact: 7044dd120f user: oehhar

Documentation of http::unregister misses return value

Closed / Fixed74bc0e44f5ec534d3c77fc8d78fd4cd08d3f9a0dCreated 10 years agoUpdated 10 years ago
Descriptionwiki2016-09-22 14:02:40

Documentation of return value of http::unregister missing

The command 'http::unregister' returns a list of Port and Command used in a former 'http::register'. This is not documented.

Documentation missing: error raised if http::unregister is called without registration

The command 'http::unregister' raises an error, if the protocol was not registered. This is not documented.

Use case

I was looking for a possibility to find out, if a 'http::register https <cmd>' was already called. This is possible with the upper information:

if {[catch { http::unregister https } lPortCmd]} {
    # not registered -> register on my own
} else {
    # Ok, was registered - reregister
    http::register https {*}$lPortCmd
}

I want to use this code in tclws to preserve an already registered handler.

Thank you, Harald

Referenced by6
patthoytshtml2016-09-22 15:14:53

It would be better to use

if {![info exists ::http::urlTypes(https)]} { ... }
I this is deemed useful on the http package api then 'http::register https' could be usefully modified to return the registration information or an empty list. That would be in keeping with [set] and so on.

oehharwiki2016-09-22 15:52:07

Pat, thanks for the message.

IMHO https and the underlaying package (tls/Twapi) and its options (tls package) are quite critical.

Thus packages which require registered https protocol should not delete a present registration, but just use it or post an error if not compatible.

To your solution: I don't like to access internals ('::http::urlTypes(https)') if they don't belong to the public interface. Tomorow, a maintainer changes the array to a dict and it does not work any more.

To your proposal, I would prefer a solution where we can explicitly query the current setting. The 'set'-semantics does not help, as it returns the value just set, not the value eventually replaced by the set.

Thank you, Harald

patthoytshtml2016-09-24 12:23:04

What I was suggesting is that this can be exposed onto the published API for use as in this example:

% package require http
2.8.9
% http::register https 443 tls::socket
443 tls::socket
% http::register https
443 tls::socket
% http::register beep
% 
Extending the http::register command to accept either a single parameter to query the set of registered protocols, or to take 3 parameters for registering a new protocol. This is in keeping with the style of many Tcl and Tk commands of which 'set' is one example. Tk widgets 'configure' commands are another, or the channel 'fconfigure' command. The changes required are pretty simple. The following should be enough.
proc http::register {args} {
    variable urlTypes
    if {[llength $args] == 1} {
        set proto [lindex $args 0]
        if {[info exists urlTypes($proto)]} {
            return $urlTypes($proto)
        } else {
            return {}
        }
    } elseif {[llength $args] == 3} {
        lassign $args proto port command
        set urlTypes([string tolower $proto]) [list $port $command]
    } else {
        return -code error \
            "wrong # args: should be http::register proto ?port command?"
    }
}
It might also be useful to make it return all the registered protocol names by passing in no parameters.

oehharwiki2016-09-24 15:12:32

Hi Pat,

yes, that is a good idea.

Nevertheless, it would require a tip, while accepting this ticket is a bug fix, much cheaper. So I will try to go this way.

Thank you, Harald

dkf Ticket [74bc0e44f5]: 3 changes [History diff]2016-10-08 17:01:05
dkfwiki2016-10-08 17:08:07

Documenting properly an existing behaviour that is actually documented in the http.tcl file is not a change in any meaningful way; we can Just Do It.

Reconsiderations of the API require opening a can of worms.

dkf Closed ticket [74bc0e44f5]. [History diff]2016-10-08 17:11:04
oehharwiki2016-10-11 13:22:52

Thank you documenting the return value by commit [6bae8fa2fdb517a7].

I would also appreciate to document, that an error is rised if there is no registration.

Thanks, Harald

dkfwiki2016-10-12 09:58:43

A fair point. Updated.

oehharwiki2016-10-12 12:53:07

Thank you for commit [238be90a8b] ! No more moaning ;-) Thanks, Harald

Log in (anonymous is fine) to add a comment.