1autoproxy(n) HTTP protocol helper modules autoproxy(n)
2
3
4
5______________________________________________________________________________
6
8 autoproxy - Automatic HTTP proxy usage and authentication
9
11 package require Tcl 8.2
12
13 package require http ?2.0?
14
15 package require autoproxy ?1.5.1?
16
17 ::autoproxy::init
18
19 ::autoproxy::cget -optionname
20
21 ::autoproxy::configure ?-option value?
22
23 ::autoproxy::tls_connect args
24
25 ::autoproxy::tunnel_connect args
26
27 ::autoproxy::tls_socket args
28
29_________________________________________________________________
30
32 This package attempts to automate the use of HTTP proxy servers in Tcl
33 HTTP client code. It tries to initialize the web access settings from
34 system standard locations and can be configured to negotiate authenti‐
35 cation with the proxy if required.
36
37 On Unix the standard for identifying the local HTTP proxy server seems
38 to be to use the environment variable http_proxy or ftp_proxy and
39 no_proxy to list those domains to be excluded from proxying. On Win‐
40 dows we can retrieve the Internet Settings values from the registry to
41 obtain pretty much the same information. With this information we can
42 setup a suitable filter procedure for the Tcl http package and arrange
43 for automatic use of the proxy.
44
45 There seem to be a number of ways that the http_proxy environment vari‐
46 able may be set up. Either a plain host:port or more commonly a URL and
47 sometimes the URL may contain authentication parameters or these may be
48 requested from the user or provided via http_proxy_user and
49 http_proxy_pass. This package attempts to deal with all these schemes.
50 It will do it's best to get the required parameters from the environ‐
51 ment or registry and if it fails can be reconfigured.
52
54 ::autoproxy::init
55 Initialize the autoproxy package from system resources. Under
56 unix this means we look for environment variables. Under windows
57 we look for the same environment variables but also look at the
58 registry settings used by Internet Explorer.
59
60 ::autoproxy::cget -optionname
61 Retrieve individual package configuration options. See OPTIONS.
62
63 ::autoproxy::configure ?-option value?
64 Configure the autoproxy package. Calling configure with no
65 options will return a list of all option names and values. See
66 OPTIONS.
67
68 ::autoproxy::tls_connect args
69 Connect to a secure socket through a proxy. HTTP proxy servers
70 permit the use of the CONNECT HTTP command to open a link
71 through the proxy to the target machine. This function hides the
72 details. For use with the http package see tls_socket.
73
74 The args list may contain any of the tls package options but
75 must end with the host and port as the last two items.
76
77 ::autoproxy::tunnel_connect args
78 Connect to a target host throught a proxy. This uses the same
79 CONNECT HTTP command as the tls_connect but does not promote the
80 link security once the connection is established.
81
82 The args list may contain any of the tls package options but
83 must end with the host and port as the last two items.
84
85 Note that many proxy servers will permit CONNECT calls to a lim‐
86 ited set of ports - typically only port 443 (the secure HTTP
87 port).
88
89 ::autoproxy::tls_socket args
90 This function is to be used to register a proxy-aware secure
91 socket handler for the https protocol. It may only be used with
92 the Tcl http package and should be registered using the
93 http::register command (see the examples below). The job of
94 actually creating the tunnelled connection is done by the
95 tls_connect command and this may be used when not registering
96 with the http package.
97
99 host hostname
100
101 proxy_host hostname
102 Set the proxy hostname. This is normally set up by init but may
103 be configured here as well.
104
105 port number
106
107 proxy_port number
108 Set the proxy port number. This is normally set up by init.
109 e.g. configure -port 3128
110
111 no_proxy list
112 You may manipulate the no_proxy list that was setup by init. The
113 value of this option is a tcl list of strings that are matched
114 against the http request host using the tcl string match com‐
115 mand. Therefore glob patterns are permitted. For instance, con‐
116 figure -no_proxy *.localdomain
117
118 authProc procedure
119 This option may be used to set an application defined procedure
120 to be called when configure -basic is called with either no or
121 insufficient authentication details. This can be used to present
122 a dialog to the user to request the additional information.
123
124 -basic Following options are for configuring the Basic authentication
125 scheme parameters. See Basic Authentication.
126
128 Basic is the simplest and most commonly use HTTP proxy authentication
129 scheme. It is described in (1 section 11) and also in (2). It offers no
130 privacy whatsoever and its use should be discouraged in favour of more
131 secure alternatives like Digest. To perform Basic authentication the
132 client base64 encodes the username and plaintext password separated by
133 a colon. This encoded text is prefixed with the word "Basic" and a
134 space.
135
136 The following options exists for this scheme:
137
138 -username name
139 The username required to authenticate with the configured proxy.
140
141 -password password
142 The password required for the username specified.
143
144 -realm realm
145 This option is not used.
146
148 package require autoproxy
149 autoproxy::init
150 autoproxy::configure -basic -username ME -password SEKRET
151 set tok [http::geturl http://wiki.tcl.tk/]
152 http::data $tok
153
154
155 package require http
156 package require tls
157 package require autoproxy
158 autoproxy::init
159 http::register https 443 autoproxy::tls_socket
160 set tok [http::geturl https://www.example.com/]
161
162
164 [1] Berners-Lee, T., Fielding R. and Frystyk, H. "Hypertext Trans‐
165 fer Protocol -- HTTP/1.0", RFC 1945, May 1996, (http://www.rfc-
166 editor.org/rfc/rfc1945.txt)
167
168 [2] Franks, J. et al. "HTTP Authentication: Basic and Digest Access
169 Authentication", RFC 2617, June 1999 (http://www.rfc-edi‐
170 tor.org/rfc/rfc2617.txt)
171
173 At this time only Basic authentication (1) (2) is supported. It is
174 planned to add support for Digest (2) and NTLM in the future.
175
177 Pat Thoyts
178
180 This document, and the package it describes, will undoubtedly contain
181 bugs and other problems. Please report such in the category http ::
182 autoproxy of the Tcllib SF Trackers [http://source‐
183 forge.net/tracker/?group_id=12883]. Please also report any ideas for
184 enhancements you may have for either package and/or documentation.
185
187 http(n)
188
190 authentication, http, proxy
191
192
193
194http 1.5.1 autoproxy(n)