Tcl Source Code

View Ticket
Login
Ticket UUID: 2964525
Title: geturl doesn't complete properly
Type: Bug Version: obsolete: 8.6b1.1
Submitter: nurdglaw Created on: 2010-03-05 21:42:17
Subsystem: 29. http Package Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2010-03-06 06:39:18
Resolution: Duplicate Closed By: ferrieux
    Closed on: 2010-03-05 23:39:18
Description:
Using http version 2.7.2 from the ActiveTcl teapot, the command [http::geturl https://www.ebu.co.uk/members/api/api.net] doesn't complete properly.

On completion [http::code] returns an emptry string.

The problem appears to occur because when http::Event is entered the first time, with state(state) = connecting, [gets] returns -1. This means that state(http) is set to an empty string, and when the last header has been read, the code returns immediately without setting state(state) to body.

I changed the code at the top of Event so that it doesn't set state to header if [gets] returns -1 and that seems to work OK for this url and one other url that I tried.

The problem doesn't occur with http 2.7 which doesn't use the state "connecting"

I'm running Ubuntu 8.04
User Comments: ferrieux added on 2010-03-06 06:39:17:
Duplicate of 2624536, fixed 2009-04-09.

nurdglaw added on 2010-03-06 04:46:44:
Sorry - can't work out how to attach another file.

Output of httpbug.tcl

patchlevel: 8.6b1.1
http: 2.7.2
tls: 1.6
http::code: 
::http::1(-binary)         = false
::http::1(-blocksize)      = 8192
::http::1(-headers)        = 
::http::1(-keepalive)      = 0
::http::1(-protocol)       = 1.1
::http::1(-queryblocksize) = 8192
::http::1(-queryprogress)  = 
::http::1(-strict)         = 1
::http::1(-timeout)        = 0
::http::1(-type)           = application/x-www-form-urlencoded
::http::1(-validate)       = 0
::http::1(binary)          = 0
::http::1(body)            = 
::http::1(charset)         = iso8859-1
::http::1(coding)          = 
::http::1(connection)      = close
::http::1(currentsize)     = 0
::http::1(http)            = 
::http::1(meta)            = Content-Type text/xml Server Microsoft-IIS/6.0 X-Powered-By PHP/5.2.4 X-Powered-By ASP.NET Date {Fri, 05 Mar 2010 20:46:39 GMT} Connection close
::http::1(querylength)     = 0
::http::1(queryoffset)     = 0
::http::1(sock)            = sock5
::http::1(socketinfo)      = www.ebu.co.uk:443
::http::1(state)           = header
::http::1(status)          = eof
::http::1(totalsize)       = 0
::http::1(type)            = text/xml
::http::1(url)             = https://www.ebu.co.uk/members/api/api.php

Applied patch:

--- 272/http-2.7.2.tm2010-03-05 21:24:59.000000000 +0000
+++ 273a1/http-2.7.2.tm2010-03-05 21:31:39.000000000 +0000
@@ -13,7 +13,7 @@
 package require Tcl 8.4
 # Keep this in sync with pkgIndex.tcl and with the install directories
 # in Makefiles
-package provide http 2.7.2
+package provide http 2.7.3a1
 
 namespace eval http {
     # Allow resourcing to not clobber existing data
@@ -943,10 +943,12 @@
 return
     }
     if {$state(state) eq "connecting"} {
-set state(state) "header"
 if {[catch {gets $sock state(http)} n]} {
     return [Finish $token $n]
 }
+if {$n != -1} {
+    set state(state) "header"
+}
     } elseif {$state(state) eq "header"} {
 if {[catch {gets $sock line} n]} {
     return [Finish $token $n]

nurdglaw added on 2010-03-06 04:42:17:

File Added - 365580: httpbug.tcl

Attachments: