geturl not working with registered protocols except tls
Attached script worked with http versions 2.9.8 and 2.10a1 and using tls or twapi for https sockets.
Current http version does not work with twapi anymore.
Error message is as follows:
Invalid option '-type'.
Must be one of -myaddr, -myport, -async, -socketcmd, -server, -peersubject, -requestclientcert, -credentials, -verifier
This seems to be caused by the new option "-type $token" when creating the openCmd:
set state(openCmd) [list {*}$defcmd {*}$sockopts -type $token {*}$targetAddr]
If I remove the "-type" option, geturl works with twapi and tls:
set state(openCmd) [list {*}$defcmd {*}$sockopts {*}$targetAddr]
Paul
I think, it is more an issue of twapi to pip-through the new option.
In consequence, I have transfered this ticket to TWAPI bugtracker (Bug 220):
https://sourceforge.net/p/twapi/bugs/220/
If this is ok for you, I may close this ticket.
Thank you and take care, Harald
Let us keep this discussion here for now please, until I understand why this is a twapi issue. What is the `-type` option and what is twapi::tls_socket supposed to do with it? The only -type option I see is for http::geturl which is a mime type but I don't think that is what this is. Harald mentions twapi should pipe through the new option, but to what? twapi::tls_socket just opens a TLS socket.
Maybe, I am just wrong. Harald
Here something curious. Am I configuring something wrong? Could someone verify you see the same result?
% package require http
2.10b1
% http::register http 80 [list socket]
80 socket
% set token [http::geturl "http://www.tcl3d.org/bawt/"]
bad option "-type": must be -async, -backlog, -myaddr, -myport, -reuseaddr, -reuseport, or -server
Same result with branch main and MS_VC2015 32 bit.
Sorry to blame great TWAPI...
Harald
Hi Ashok, I see the same error message when executing your script. It does work, if I remove the http::register command. Added a puts command to print the state(openCmd) value: Using http::register : socket -async -type ::http::1 www.tcl3d.org 80 Without http::register: ::http::socket -async -type ::http::1 www.tcl3d.org 80 In the latter case, the replacement proc http::socket is called, which uses the token value to store a thread id. Maybe there should be a condition, when building the state(openCmd) string, if the called socket command is http::socket or a command specified with http::register? Paul
Looking at why tls::socket works but not socket or twapi::tls_socket, the tls::socket is special cased by the http package and routed through socketForTls and SecureProxyConnect. The latter actually handles or at least checks for the -type option. But I don't really know how it all hangs together.
Given that http::register fails for plain old Tcl socket as well (Harald, thanks for verifying), I'm taking the liberty of changing the bug title.
Paul, You're probably on the right track but I'll let someone who knows the code (@kjnash?) look into it. /Ashok
Fixed by Keith, thanks !
Here is the commit to core-8-branch: [7759882996].
New docs explain what is going on.
Thank you all, Harald