summaryrefslogtreecommitdiffstats
path: root/library/http/http.tcl
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2008-02-26 19:52:52 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2008-02-26 19:52:52 (GMT)
commit4af7381c98a78ec974b2febf9fc9543d2fa04e8f (patch)
treeb0e168a9a70296f6f8bbc9c166289776fd5e41c4 /library/http/http.tcl
parent27be8caf52c5e17142a83ab813d24074a6e1fbee (diff)
downloadtcl-4af7381c98a78ec974b2febf9fc9543d2fa04e8f.zip
tcl-4af7381c98a78ec974b2febf9fc9543d2fa04e8f.tar.gz
tcl-4af7381c98a78ec974b2febf9fc9543d2fa04e8f.tar.bz2
Set version 2.5.5
bug #1868845 - it is better to do the [eof] check after trying to read from the socket. No clashes found in testing. Added http::meta command to access the http headers.
Diffstat (limited to 'library/http/http.tcl')
-rw-r--r--library/http/http.tcl24
1 files changed, 15 insertions, 9 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 2888def..b8764b4 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: http.tcl,v 1.61 2008/02/22 10:56:40 patthoyts Exp $
+# RCS: @(#) $Id: http.tcl,v 1.62 2008/02/26 19:52:54 patthoyts Exp $
# Rough version history:
# 1.0 Old http_get interface.
@@ -24,7 +24,7 @@
package require Tcl 8.4
# Keep this in sync with pkgIndex.tcl and with the install directories
# in Makefiles
-package provide http 2.5.4
+package provide http 2.5.5
namespace eval http {
variable http
@@ -655,7 +655,11 @@ proc http::size {token} {
upvar 0 $token state
return $state(currentsize)
}
-
+proc http::meta {token} {
+ variable $token
+ upvar 0 $token state
+ return $state(meta)
+}
proc http::error {token} {
variable $token
upvar 0 $token state
@@ -786,13 +790,9 @@ proc http::Event {token} {
upvar 0 $token state
set s $state(sock)
- if {[eof $s]} {
- Eof $token
- return
- }
if {$state(state) eq "header"} {
if {[catch {gets $s line} n]} {
- Finish $token $n
+ return [Finish $token $n]
} elseif {$n == 0} {
variable encodings
set state(state) body
@@ -820,6 +820,7 @@ proc http::Event {token} {
# Initiate a sequence of background fcopies
fileevent $s readable {}
CopyStart $s $token
+ return
}
} elseif {$n > 0} {
if {[regexp -nocase {^content-type:(.+)$} $line x type]} {
@@ -854,7 +855,7 @@ proc http::Event {token} {
incr state(currentsize) $n
}
} err]} {
- Finish $token $err
+ return [Finish $token $err]
} else {
if {[info exists state(-progress)]} {
eval $state(-progress) \
@@ -862,6 +863,11 @@ proc http::Event {token} {
}
}
}
+
+ if {[eof $s]} {
+ Eof $token
+ return
+ }
}
# http::CopyStart