Tcl Source Code

View Ticket
Login
Ticket UUID: 8c3de5039a95a1a173c0ddfb7b5d27cae0d20fad
Title: geturl not working with registered protocols except tls
Type: Bug Version: 2.10b1
Submitter: anonymous Created on: 2023-10-07 19:33:04
Subsystem: 29. http Package Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-12-13 11:18:25
Resolution: Fixed Closed By: oehhar
    Closed on: 2023-12-13 11:18:25
Description:
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
User Comments: oehhar added on 2023-12-13 11:18:25:

Fixed by Keith, thanks !

Here is the commit to core-8-branch: [7759882996].

New docs explain what is going on.

Thank you all, Harald


apnadkarni added on 2023-10-10 17:18:31:
Paul,

You're probably on the right track but I'll let someone who knows the code (@kjnash?) look into it.

/Ashok

apnadkarni added on 2023-10-10 17:16:11:

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.


anonymous added on 2023-10-10 17:09:33:
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

oehhar added on 2023-10-10 16:22:21:

Same result with branch main and MS_VC2015 32 bit.

Sorry to blame great TWAPI...

Harald


apnadkarni added on 2023-10-10 15:57:47:

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

oehhar added on 2023-10-10 15:46:06:

Maybe, I am just wrong. Harald


apnadkarni added on 2023-10-10 15:35:51:
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.

oehhar added on 2023-10-10 09:33:10:

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


Attachments: