Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 38f8b9dd84308e4293d340da6d00fbb5d92b61df
Ticket: 420060ffffffffffffffffffffffffffffffffff
Add -address option to http::geturl
User & Date: bbeacham on 2001-04-30 04:13:40
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    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. 
    
    
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "bbeacham"
  9. subsystem changed to: "29. http Package"
  10. title changed to: "Add -address option to http::geturl"
  11. type changed to: "Patch"