Tcl Source Code

Check-in [1fe8ca8d3e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Horrible hack to keep the old error message.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1fe8ca8d3eb87b656d1be832aad5270d17c40bec
User & Date: dkf 2005-01-06 15:15:42
Context
2005-01-09
19:31
Remove readdir_r() and related #ifdeffery (see #1095909). Don't check for HAVE_READDIR_R. Regenerat... check-in: 7345fd05ed user: jenglish tags: trunk
2005-01-06
15:15
Horrible hack to keep the old error message. check-in: 1fe8ca8d3e user: dkf tags: trunk
11:15
Performance updates to http::mapReply [1020491] and fix version numbering. check-in: 78058a0d6f user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to library/http/http.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# http.tcl --
#
#	Client-side HTTP for GET, POST, and HEAD commands.
#	These routines can be used in untrusted code that uses 
#	the Safesock security policy.  These procedures use a 
#	callback interface to avoid using vwait, which is not 
#	defined in the safe base.
#
# 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.49 2005/01/06 11:15:21 dkf Exp $

# Rough version history:
# 1.0	Old http_get interface
# 2.0	http:: namespace and http::geturl
# 2.1	Added callbacks to handle arriving data, and timeouts
# 2.2	Added ability to fetch into a channel
# 2.3	Added SSL support, and ability to post from a channel











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# http.tcl --
#
#	Client-side HTTP for GET, POST, and HEAD commands.
#	These routines can be used in untrusted code that uses 
#	the Safesock security policy.  These procedures use a 
#	callback interface to avoid using vwait, which is not 
#	defined in the safe base.
#
# 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.50 2005/01/06 15:15:42 dkf Exp $

# Rough version history:
# 1.0	Old http_get interface
# 2.0	http:: namespace and http::geturl
# 2.1	Added callbacks to handle arriving data, and timeouts
# 2.2	Added ability to fetch into a channel
# 2.3	Added SSL support, and ability to post from a channel
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	-urlencoding utf-8
    }
    set http(-useragent) "Tcl http client package [package provide http]"

    proc init {} {
	# Set up the map for quoting chars
	# The spec says: "non-alphanumeric characters are replaced by '%HH'"
	for {set i 0} {$i <= 256} {incr i} {
	    set c [format %c $i]
	    if {![string match {[a-zA-Z0-9]} $c]} {
		set map($c) %[format %.2x $i]
	    }
	}
	# These are handled specially
	array set map { " " + \n %0d%0a }







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	-urlencoding utf-8
    }
    set http(-useragent) "Tcl http client package [package provide http]"

    proc init {} {
	# Set up the map for quoting chars
	# The spec says: "non-alphanumeric characters are replaced by '%HH'"
	for {set i 0} {$i < 256} {incr i} {
	    set c [format %c $i]
	    if {![string match {[a-zA-Z0-9]} $c]} {
		set map($c) %[format %.2x $i]
	    }
	}
	# These are handled specially
	array set map { " " + \n %0d%0a }
892
893
894
895
896
897
898

899
900







901
902
903
904
905
906
907

    # The spec says: "non-alphanumeric characters are replaced by '%HH'"
    # Use a pre-computed map and [string map] to do the conversion
    # (much faster than [regsub]/[subst]). [Bug 1020491]

    if {$http(-urlencoding) ne ""} {
	set string [encoding convertto $http(-urlencoding) $string]

    }
    return [string map $formMap $string]







}

# http::ProxyRequired --
#	Default proxy filter. 
#
# Arguments:
#	host	The destination host







>

|
>
>
>
>
>
>
>







892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915

    # The spec says: "non-alphanumeric characters are replaced by '%HH'"
    # Use a pre-computed map and [string map] to do the conversion
    # (much faster than [regsub]/[subst]). [Bug 1020491]

    if {$http(-urlencoding) ne ""} {
	set string [encoding convertto $http(-urlencoding) $string]
	return [string map $formMap $string]
    }
    set converted [string map $formMap $string]
    if {[string match "*\[\u0100-\uffff\]*" $converted]} {
	regexp {[\u0100-\uffff]} $converted badChar
	# Return this error message for maximum compatability... :^/
	return -code error \
	    "can't read \"formMap($badChar)\": no such element in array"
    }
    return $converted
}

# http::ProxyRequired --
#	Default proxy filter. 
#
# Arguments:
#	host	The destination host