diff options
author | hobbs <hobbs> | 2003-07-18 19:41:15 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-07-18 19:41:15 (GMT) |
commit | 5635211afddc3042c08fae33be07d6bae4653761 (patch) | |
tree | 38fb4d979bf1f154bb2e18ae4be63725e06168c0 /library | |
parent | c51028043b021ffab282d631fa8d2966f6b60e8a (diff) | |
download | tcl-5635211afddc3042c08fae33be07d6bae4653761.zip tcl-5635211afddc3042c08fae33be07d6bae4653761.tar.gz tcl-5635211afddc3042c08fae33be07d6bae4653761.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)
Diffstat (limited to 'library')
-rw-r--r-- | library/http/http.tcl | 23 | ||||
-rw-r--r-- | library/http/pkgIndex.tcl | 2 |
2 files changed, 14 insertions, 11 deletions
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}}}] |