|
2001-09-07
| ||
| 06:02 | • Closed ticket [420060ffff]: Add -address option to http::geturl plus 7 other... artifact: 007efe5a60 user: hobbs | |
|
2001-08-25
| ||
| 00:56 | • Ticket [420060ffff]: 5 changes artifact: 217818f580 user: andreas_kupries | |
|
2001-05-22
| ||
| 06:32 | • Ticket [420060ffff]: 4 changes artifact: 8674286076 user: hobbs | |
|
2001-04-30
| ||
| 04:13 | • New ticket [420060ffff]. artifact: 38f8b9dd84 user: bbeacham | |
Add -address option to http::geturl
Closed / Rejected420060ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2001-04-30 04:13:40
Issue:
Linux allows multiple IP addresses to be bound to a
single NIC card. This gives someone the ability to
write applications that appear to generate traffic
from multiple clients from a single PC.
Problem:
The TCL library function HTTP::GETURL only uses the
first IP bound to the computer.
Solution:
HTTP::GETURL uses the TCL socket command to setup the
connection. Socket has an option, -myaddr, that
allows an IP address to be passed to the socket. This
will be the IP addresses used for the conection.
I modified HTTP::GETURL to allow an IP address to be
passed to it. It then gets passed to socket. Now I
can generate HTTPS GETs from a number of unique
clients while using a single PC.
Note: After I posted this on USENET someone showed
how to use http::register to set the system IP to a
differant IP and then that would be the IP used by
http::geturl. However, that is not as clean and
simple as having an address option. Also it creates a
lot of CPU overhead having to call it each time you
loop through a range of IP addresses.
Modified TCL 8.3 ...../lib/tcl8.3/http2.3/http.tcl
proc http::geturl { url args } {
...deleted stuff....
# Process command options.
array set state {
-blocksize 8192
-queryblocksize 8192
-validate 0
-headers {}
-timeout 0
-type application/x-www-form-urlencoded
-queryprogress {}
-address {} ;# added to allow addresses
state header
meta {}
currentsize 0
totalsize 0
querylength 0
queryoffset 0
type text/html
body {}
status ""
http ""
}
set options {-blocksize -channel -command -handler -
headers \
-progress -query -queryblocksize -
querychannel -queryprogress\
-validate -timeout -type -address}
...deleted stuff......
# this is where the enhancement patch executes
# I am unsure if the first "if" needs to be modified
or not
if {[info exists phost] && [string length $phost]} {
set srvurl $url
set conStat [catch {eval $defcmd $async {$phost
$pport}} s]
} elseif {$state(-address) == ""} { ;# changed else
to elseif - system default address, option not used
set conStat [catch {eval $defcmd $async {$host
$port}} s]
} else { ;# added else, set statement, and -
myaddr $state(-address)
set conStat [catch {eval $defcmd $async {-
myaddr $state(-address) $host $port}} s]
}
Example:
set result [catch {http::geturl $url -timeout $TIMEOUT
\
-headers "Cookie $cookie($localIp,$url)" \
-address $localIp} token]
Documentation:
::http::geturl url ?options?
The ::http::geturl command is the main procedure in
the package. The -query option causes a POST operation
and the -validate option causes a HEAD operation;
otherwise, a GET operation is performed.
The ::http::geturl command returns a token value that
can be used to get information about the transaction.
See the STATE ARRAY and ERRORS section for details.
The ::http::geturl command blocks until the operation
completes, unless the -command option specifies a
callback that is invoked when the HTTP transaction
completes. ::http::geturl takes several options:
-address addr (borrowed from the -myaddr description
in the socket documentation and added this part: "or
multiple addresses bound to a network interface")
Addr gives the domain-style name or numerical IP
address of the client-side network interface to use
for the connection. This option may be useful if the
client machine has multiple network interfaces, or
multiple addresses bound to a network interface. If
the option is omitted then the client-side interface
will be chosen by the system software.
hobbsplain2001-05-22 06:32:19
Logged In: YES user_id=72656 This is a good idea, but can we get it reduced to a simple patch against the current sources for easier analysis and inclusion?
andreas_kupriesplain2001-08-25 00:56:48
Logged In: YES user_id=75003 Seems not, given the quietness.
hobbsplain2001-09-07 06:02:51
Logged In: YES
user_id=72656
The problem is that with the new http::register, this
becomes very difficult to implement with an address option
instead of using the register. You can just do:
http::register 192http 80 [list ::socket -myaddr 192...]
http::register 10http 80 [list ::socket -myaddr 10...]
and so on. Any geturl with http://... will use the first
system IP given, but 192http:// and 10http:// would use a
specific address. Whereas you wanted:
geturl -addr $myaddr $url
you would now do:
set addr 127.0.0.1
register ${addr}http 80 [list ::socket -myaddr $addr]
geturl $addr$url
maybe not as elegant, but seems good enough to me.
Log in (anonymous is fine) to add a comment.