summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-07-18 19:41:15 (GMT)
committerhobbs <hobbs>2003-07-18 19:41:15 (GMT)
commitf25190b7b14bee012d5f29e0cb1ebc6cedb98527 (patch)
tree38fb4d979bf1f154bb2e18ae4be63725e06168c0
parente7fe85a9c83ac99d29c83dc003abe20abe576c57 (diff)
downloadtcl-f25190b7b14bee012d5f29e0cb1ebc6cedb98527.zip
tcl-f25190b7b14bee012d5f29e0cb1ebc6cedb98527.tar.gz
tcl-f25190b7b14bee012d5f29e0cb1ebc6cedb98527.tar.bz2
* library/http/pkgIndex.tcl: merged to v2.4.4 from head
* library/http/http.tcl: add support for user:pass info in URL. * tests/http.test: [Bug 759888] (shiobara)
-rw-r--r--ChangeLog9
-rw-r--r--library/http/http.tcl23
-rw-r--r--library/http/pkgIndex.tcl2
-rw-r--r--tests/http.test8
4 files changed, 28 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 10dccbd..1847cb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-18 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * library/http/pkgIndex.tcl: merged to v2.4.4 from head
+ * library/http/http.tcl: add support for user:pass info in URL.
+ * tests/http.test: [Bug 759888] (shiobara)
+
2003-07-18 Don Porter <dgp@users.sourceforge.net>
* doc/AddErrInfo.3: Improved consistency of documentation
@@ -28,11 +34,10 @@
* generic/tclFileName.c (Tcl_TranslateFileName): And remove from here.
(TclDoGlob): Adjust for cygwin and append / for dirs instead of \
* win/tclWinFile.c (TclpObjChdir): Use chdir on Cygwin.
+ [Patch 679315]
2003-07-16 Jeff Hobbs <jeffh@ActiveState.com>
- * win/tclWinFile.c (TclpObjChdir):
-
* library/safe.tcl (FileInAccessPath): normalize paths before
comparison. [Bug 759607] (myers)
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 7ae2286..2a9c8b5 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -9,7 +9,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.43 2002/10/03 13:34:32 dkf Exp $
+# RCS: @(#) $Id: http.tcl,v 1.43.2.1 2003/07/18 19:41:16 hobbs Exp $
# Rough version history:
# 1.0 Old http_get interface
@@ -25,7 +25,7 @@
package require Tcl 8.2
# keep this in sync with pkgIndex.tcl
# and with the install directories in Makefiles
-package provide http 2.4.2
+package provide http 2.4.4
namespace eval http {
variable http
@@ -119,7 +119,7 @@ proc http::config {args} {
}
return $result
}
- regsub -all -- - $options {} options
+ set options [string map {- ""} $options]
set pat ^-([join $options |])$
if {[llength $args] == 1} {
set flag [lindex $args 0]
@@ -260,7 +260,7 @@ proc http::geturl { url args } {
-progress -query -queryblocksize -querychannel -queryprogress\
-validate -timeout -type}
set usage [join $options ", "]
- regsub -all -- - $options {} options
+ set options [string map {- ""} $options]
set pat ^-([join $options |])$
foreach {flag value} $args {
if {[regexp $pat $flag]} {
@@ -288,9 +288,11 @@ proc http::geturl { url args } {
}
# Validate URL, determine the server host and port, and check proxy case
+ # Recognize user:pass@host URLs also, although we do not do anything
+ # with that info yet.
- if {![regexp -nocase {^(([^:]*)://)?([^/:]+)(:([0-9]+))?(/.*)?$} $url \
- x prefix proto host y port srvurl]} {
+ set exp {^(([^:]*)://)?([^@]+@)?([^/:]+)(:([0-9]+))?(/.*)?$}
+ if {![regexp -nocase $exp $url x prefix proto user host y port srvurl]} {
unset $token
return -code error "Unsupported URL: $url"
}
@@ -414,7 +416,7 @@ proc http::geturl { url args } {
}
puts $s "User-Agent: $http(-useragent)"
foreach {key value} $state(-headers) {
- regsub -all \[\n\r\] $value {} value
+ set value [string map [list \n "" \r ""] $value]
set key [string trim $key]
if {[string equal $key "Content-Length"]} {
set contDone 1
@@ -678,8 +680,9 @@ proc http::Event {token} {
} elseif {$n == 0} {
variable encodings
set state(state) body
- if {$state(-binary) || ![regexp -nocase ^text $state(type)] || \
- [regexp gzip|compress $state(coding)]} {
+ if {$state(-binary) || ![string match -nocase text* $state(type)]
+ || [string match *gzip* $state(coding)]
+ || [string match *compress* $state(coding)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary
if {[info exists state(-channel)]} {
@@ -716,7 +719,7 @@ proc http::Event {token} {
}
if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
lappend state(meta) $key [string trim $value]
- } elseif {[regexp ^HTTP $line]} {
+ } elseif {[string match HTTP* $line]} {
set state(http) $line
}
}
diff --git a/library/http/pkgIndex.tcl b/library/http/pkgIndex.tcl
index 8461a67..82c68f5 100644
--- a/library/http/pkgIndex.tcl
+++ b/library/http/pkgIndex.tcl
@@ -9,4 +9,4 @@
# full path name of this file's directory.
if {![package vsatisfies [package provide Tcl] 8.2]} {return}
-package ifneeded http 2.4.2 [list tclPkgSetup $dir http 2.4.2 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister}}}]
+package ifneeded http 2.4.4 [list tclPkgSetup $dir http 2.4.4 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister}}}]
diff --git a/tests/http.test b/tests/http.test
index 4beba00..1051162 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -12,7 +12,7 @@
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#
-# RCS: @(#) $Id: http.test,v 1.33 2003/02/11 20:41:38 kennykb Exp $
+# RCS: @(#) $Id: http.test,v 1.33.2.1 2003/07/18 19:41:17 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -133,6 +133,7 @@ test http-3.3 {http::geturl} {
set tail /a/b/c
set url [info hostname]:$port/a/b/c
+set fullurl http://user:pass@[info hostname]:$port/a/b/c
set binurl [info hostname]:$port/binary
set posturl [info hostname]:$port/post
set badposturl [info hostname]:$port/droppost
@@ -308,6 +309,11 @@ test http-3.13 {http::geturl socket leak test} {
expr {[llength [file channels]] == $chanCount}
} 1
+test http-3.14 "http::geturl $fullurl" {
+ set token [http::geturl $fullurl -validate 1]
+ http::code $token
+} "HTTP/1.0 200 OK"
+
test http-4.1 {http::Event} {
set token [http::geturl $url]
upvar #0 $token data