set force_conservative 0 ;
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set delay 3
catch {set delay [expr int([lindex $argv 0])]}
proc delay {} {
global delay
sleep $delay
}
set timeout -1
spawn $env(SHELL)
match_max 100000
expect -glob "> "
send -- "telnet localhost 80\r"
expect -glob "Trying 127.0.0.1...\r\r
Connected to localhost.\r\r
Escape character is '^\]'.\r\r
"
delay
send -- "POST /cgi-bin/test.cgi HTTP/1.0\r"
expect -glob " HTTP/1.?\r
"
delay
send -- "Connection: Keep-Alive\r"
expect -glob "\r
"
delay
set content "VAR1=123&VAR2=xyz\r\n"
send -- "Content-Type: application/x-www-form-urlencoded\r"
expect -glob "\r
"
delay
send -- "Content-Length: [string length $content]\r"
expect -glob "\r
"
delay
send -- "\r"
expect -glob "\r
"
delay
send -- $content
expect -glob $content
expect -glob "
Connection closed by foreign host.\r\r
"
delay
expect "> "
send -- "exit\r"
expect eof