Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-01-09
21:18 • Closed ticket [3599395fff]: http assumes status line is a proper tcl list pl... artifact: 654222b7fe user: nijtmans
2013-01-07
20:08 • Ticket [3599395fff]: 4 changes artifact: 9700ae640e user: sebres
19:29 • Add attachment http.tcl.patch to ticket [3599395fff] artifact: ffc638bc2d user: sebres
19:29 • Ticket [3599395fff] http assumes status line is a proper tcl list status sti... artifact: c95338fe1c user: sebres
19:28 • Ticket [3599395fff]: 4 changes artifact: 7e4c4eadc1 user: sebres
2013-01-05
01:55 • Ticket [3599395fff]: 4 changes artifact: 76dda01fd9 user: dvrsn
2013-01-04
08:49 • Ticket [3599395fff]: 4 changes artifact: a3f6a17318 user: dkf
00:30 • New ticket [3599395fff]. artifact: c0a21d0069 user: dvrsn

http assumes status line is a proper tcl list

Closed / Fixed3599395fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-01-04 00:30:43
The http package implicitly assumes that the response status line is a proper tcl list.  The http specification does not guarantee this:
      Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
      Reason-Phrase  = *<TEXT, excluding CR, LF>

If the http status like is, for example
HTTP/1.0 200 This server is "ok", for now
http::geturl will choke on it with an error like

list element in quotes followed by "," instead of space
    while executing
"lindex $state(http) 1"
    (procedure "http::Event" line 26)
    invoked from within
"http::Event sock6 ::http::2"

The line at fault appears to be
            if {$state(http) == "" || [lindex $state(http) 1] == 100} {

Changing that to 
            if {$state(http) == "" || [string is list $state(http)] && [lindex $state(http) 1] == 100} {

would fix this error, although it might then miss the "100 Continue" status it was looking for.
dkfplain2013-01-04 08:49:42
It would be more elegant to parse the first line properly according to the spec (version id <SPACE> code <SPACE> arbitrary string <EOL>) as that avoids other problems. Probably also ought to check that the version id is something we grok, to avoid the weird problems documented in another bug report (whose number I forget) where the server didn't bother to send back any HTTP headers at all...

Which version of Tcl (or the http package) is this a bug report for?
dvrsnplain2013-01-05 01:55:02
I initially encountered this problem with tcl 8.5/http 2.7.2, but it still occurs with tcl 8.6/http 2.8.4.
sebresplain2013-01-07 19:28:41
Sorry, I've already fixed this problem for me in 8.5, but forgot it to announce...
Patch for http 2.7.10 is attached...
sebresplain2013-01-07 19:29:35
File Added - 458882: http.tcl.patch
sebresplain2013-01-07 20:08:30
If we are talking about the topic of HTTP, I had still an issue with KeepAlive (and forget as well to annonce you the patch). Unfortunately, I have no test case for this. But it is understandable by patch.
see bug 3599789
nijtmansplain2013-01-09 21:18:59
Fixed in core-8-5-branch and trunk
Log in (anonymous is fine) to add a comment.

Attachments: